protected void configure() {
		String className = AsyncFileLogger.class.getName();
		ClassLoader cl = Thread.currentThread().getContextClassLoader();

		// Get configured log directory
		directory = getProperty(className + ".directory", "");
		if (directory.isEmpty()) {
			directory = getProperty("moleculer.log.directory", "");
		}

		// Automatic directory selection
		// services.moleculer.logger.AsyncFileLogger.directory = #AUTO
		if (directory.startsWith("#")) {
			String found = null;

			// Detect by "catalina.home" System Property
			String path = System.getProperty("catalina.home");
			if (path != null && path.length() > 0) {
				File test = new File(path, "logs");
				if (test.isDirectory()) {
					found = test.getAbsolutePath();
				}
			}

			// Detect by classpath
			if (found == null) {

				// Lehetséges útvonalak
				HashSet<String> paths = new HashSet<String>();
				paths.add("/moleculer");
				paths.add("/Program Files/moleculer");
				paths.add("/Program Files (x86)/moleculer");
				paths.add("/opt/moleculer");

				String cp = System.getProperty("java.class.path");
				if (paths != null) {
					String pathSeparator = System.getProperty("path.separator");
					if (pathSeparator == null || pathSeparator.length() == 0) {
						pathSeparator = ";:";
					}
					StringTokenizer st = new StringTokenizer(cp, pathSeparator);
					while (st.hasMoreTokens()) {
						path = st.nextToken().trim();
						if (path.length() > 0) {
							path = path.replace('\\', '/');
							int index = path.lastIndexOf('/');
							if (index > -1) {
								path = path.substring(0, index);
							}
							paths.add(path);
						}
					}
				}
				for (String test : paths) {
					found = findLogDirectory(new File(test));
					if (found != null) {
						found = found.replace('\\', '/');
						break;
					}
				}
			}
			if (found == null) {
				found = System.getProperty("user.home", "") + "/logs";
			}
			directory = found;
		}

		if (directory.isEmpty()) {
			logDirectory = null;
		} else {
			logDirectory = new File(directory);
			if (!logDirectory.isDirectory()) {
				logDirectory.mkdirs();
			}
		}

		if (prefix == null) {
			prefix = getProperty(className + ".prefix", "moleculer-");
		}

		// Set 'compress after days' property
		String day = getProperty(className + ".compressAfter", "");
		if (!day.isEmpty()) {
			if (!day.endsWith("days")) {
				throw new IllegalArgumentException("The \"compressAfter\" must be in days (eg. \"14 days\")!");
			}
			compressAfterDays = Integer.parseInt(day.substring(0, day.length() - 4).trim());
		}

		// Set "delete after days" property
		day = getProperty(className + ".deleteAfter", "");
		if (!day.isEmpty()) {
			if (!day.endsWith("days")) {
				throw new IllegalArgumentException("The \"deleteAfter\" must be in days (eg. \"14 days\")!");
			}
			deleteAfterDays = Integer.parseInt(day.substring(0, day.length() - 4).trim());
			if (deleteAfterDays < compressAfterDays || compressAfterDays < 2 || deleteAfterDays < 2) {
				throw new IllegalArgumentException("Invalid values (delete logs after " + deleteAfterDays
						+ " days, compress logs after " + compressAfterDays + " days)!");
			}
		}

		// Set formatter
		String formatterName = getProperty(className + ".formatter", null);
		if (formatterName != null && !formatterName.isEmpty()) {
			try {
				setFormatter((Formatter) cl.loadClass(formatterName).newInstance());
			} catch (Exception ignored) {
			}
		}
		if (getFormatter() == null) {
			setFormatter(new FastLogFormatter());
		}

		// Set file encoding
		fileEncoding = getProperty(className + ".encoding", "UTF8");

		// Log to console
		logToConsole = Boolean.parseBoolean(getProperty(className + ".logToConsole", "false"));

		// Enable colors
		enableColors = Boolean.parseBoolean(getProperty(className + ".enableColors", "true"));

		// Set level
		setLevel(Level.parse(getProperty(className + ".level", Level.INFO.toString())));

		// Print log directory
		if (logDirectory != null) {
			try {
				LogRecord record = new LogRecord(Level.INFO,
						"Directory of log files: " + logDirectory.getCanonicalPath());
				record.setSourceClassName(AsyncFileLogger.class.getName());
				publish(record);
			} catch (Exception cause) {
				cause.printStackTrace();
			}
		}
	}
protected void configure ( ) { String className = AsyncFileLogger . class . getName ( ) ; ClassLoader cl = Thread . currentThread ( ) . getContextClassLoader ( ) ; directory = getProperty ( className + ".directory" , "" ) ; if ( directory . isEmpty ( ) ) { directory = getProperty ( "moleculer.log.directory" , "" ) ; } if ( directory . startsWith ( "#" ) ) { String found = null ; String path = System . getProperty ( "catalina.home" ) ; if ( path != null && path . length ( ) > 0 ) { File test = new File ( path , "logs" ) ; if ( test . isDirectory ( ) ) { found = test . getAbsolutePath ( ) ; } } if ( found == null ) { HashSet < String > paths = new HashSet < String > ( ) ; paths . add ( "/moleculer" ) ; paths . add ( "/Program Files/moleculer" ) ; paths . add ( "/Program Files (x86)/moleculer" ) ; paths . add ( "/opt/moleculer" ) ; String cp = System . getProperty ( "java.class.path" ) ; if ( paths != null ) { String pathSeparator = System . getProperty ( "path.separator" ) ; if ( pathSeparator == null || pathSeparator . length ( ) == 0 ) { pathSeparator = ";:" ; } StringTokenizer st = new StringTokenizer ( cp , pathSeparator ) ; while ( st . hasMoreTokens ( ) ) { path = st . nextToken ( ) . trim ( ) ; if ( path . length ( ) > 0 ) { path = path . replace ( '\\' , '/' ) ; int index = path . lastIndexOf ( '/' ) ; if ( index > - 1 ) { path = path . substring ( 0 , index ) ; } paths . add ( path ) ; } } } for ( String test : paths ) { found = findLogDirectory ( new File ( test ) ) ; if ( found != null ) { found = found . replace ( '\\' , '/' ) ; break ; } } } if ( found == null ) { found = System . getProperty ( "user.home" , "" ) + "/logs" ; } directory = found ; } if ( directory . isEmpty ( ) ) { logDirectory = null ; } else { logDirectory = new File ( directory ) ; if ( ! logDirectory . isDirectory ( ) ) { logDirectory . mkdirs ( ) ; } } if ( prefix == null ) { prefix = getProperty ( className + ".prefix" , "moleculer-" ) ; } String day = getProperty ( className + ".compressAfter" , "" ) ; if ( ! day . isEmpty ( ) ) { if ( ! day . endsWith ( "days" ) ) { throw new IllegalArgumentException ( "The \"compressAfter\" must be in days (eg. \"14 days\")!" ) ; } compressAfterDays = Integer . parseInt ( day . substring ( 0 , day . length ( ) - 4 ) . trim ( ) ) ; } day = getProperty ( className + ".deleteAfter" , "" ) ; if ( ! day . isEmpty ( ) ) { if ( ! day . endsWith ( "days" ) ) { throw new IllegalArgumentException ( "The \"deleteAfter\" must be in days (eg. \"14 days\")!" ) ; } deleteAfterDays = Integer . parseInt ( day . substring ( 0 , day . length ( ) - 4 ) . trim ( ) ) ; if ( deleteAfterDays < compressAfterDays || compressAfterDays < 2 || deleteAfterDays < 2 ) { throw new IllegalArgumentException ( "Invalid values (delete logs after " + deleteAfterDays + " days, compress logs after " + compressAfterDays + " days)!" ) ; } } String formatterName = getProperty ( className + ".formatter" , null ) ; if ( formatterName != null && ! formatterName . isEmpty ( ) ) { try { setFormatter ( ( Formatter ) cl . loadClass ( formatterName ) . newInstance ( ) ) ; } catch ( Exception ignored ) { } } if ( getFormatter ( ) == null ) { setFormatter ( new FastLogFormatter ( ) ) ; } fileEncoding = getProperty ( className + ".encoding" , "UTF8" ) ; logToConsole = Boolean . parseBoolean ( getProperty ( className + ".logToConsole" , "false" ) ) ; enableColors = Boolean . parseBoolean ( getProperty ( className + ".enableColors" , "true" ) ) ; setLevel ( Level . parse ( getProperty ( className + ".level" , Level . INFO . toString ( ) ) ) ) ; if ( logDirectory != null ) { try { LogRecord record = new LogRecord ( Level . INFO , "Directory of log files: " + logDirectory . getCanonicalPath ( ) ) ; record . setSourceClassName ( AsyncFileLogger . class . getName ( ) ) ; publish ( record ) ; } catch ( Exception cause ) { cause . printStackTrace ( ) ; } } }
--- CONFIGURATION ---