/** * Configure logging without reading a log4j2.properties file, effectively configuring the * status logger and all loggers to the console. * * @param settings for configuring logger.level and individual loggers */ public static void configureWithoutConfig(final Settings settings) { Objects.requireNonNull(settings); // we initialize the status logger immediately otherwise Log4j will complain when we try to get the context configureStatusLogger(); configureLoggerLevels(settings); }
/** * Configure logging without reading a log4j2.properties file, effectively configuring the * status logger and all loggers to the console. * * @param settings for configuring logger.level and individual loggers */ public static void configureWithoutConfig(final Settings settings) { Objects.requireNonNull(settings); // we initialize the status logger immediately otherwise Log4j will complain when we try to get the context configureStatusLogger(); configureLoggerLevels(settings); }
/** * Configure logging without reading a log4j2.properties file, effectively configuring the * status logger and all loggers to the console. * * @param settings for configuring logger.level and individual loggers */ public static void configureWithoutConfig(final Settings settings) { Objects.requireNonNull(settings); // we initialize the status logger immediately otherwise Log4j will complain when we try to get the context configureStatusLogger(); configureLoggerLevels(settings); }
/** * Configure logging without reading a log4j2.properties file, effectively configuring the * status logger and all loggers to the console. * * @param settings for configuring logger.level and individual loggers */ public static void configureWithoutConfig(final Settings settings) { Objects.requireNonNull(settings); // we initialize the status logger immediately otherwise Log4j will complain when we try to get the context configureStatusLogger(); configureLoggerLevels(settings); }
private static void configure(final Settings settings, final Path configsPath, final Path logsPath) throws IOException, UserException { Objects.requireNonNull(settings); Objects.requireNonNull(configsPath); Objects.requireNonNull(logsPath); setLogConfigurationSystemProperty(logsPath, settings); // we initialize the status logger immediately otherwise Log4j will complain when we try to get the context configureStatusLogger(); final LoggerContext context = (LoggerContext) LogManager.getContext(false); final List<AbstractConfiguration> configurations = new ArrayList<>(); final PropertiesConfigurationFactory factory = new PropertiesConfigurationFactory(); final Set<FileVisitOption> options = EnumSet.of(FileVisitOption.FOLLOW_LINKS); Files.walkFileTree(configsPath, options, Integer.MAX_VALUE, new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException { if (file.getFileName().toString().equals("log4j2.properties")) { configurations.add((PropertiesConfiguration) factory.getConfiguration(context, file.toString(), file.toUri())); } return FileVisitResult.CONTINUE; } }); if (configurations.isEmpty()) { throw new UserException( ExitCodes.CONFIG, "no log4j2.properties found; tried [" + configsPath + "] and its subdirectories"); } context.start(new CompositeConfiguration(configurations)); warnIfOldConfigurationFilePresent(configsPath); configureLoggerLevels(settings); }