Hi, Have recently converted a standalone (Java SE) application from JUL to Log4j2. The app has a properties file that users fill out with information about how the application should run, including information about log levels and log file location. So at startup we don't have this information until we parse the properties file, and then we set it programmatically with a ConfigurationBuilder. Through some debugging, I've made sure no classes loaded before logging is initialized have static loggers to trigger a config error. This all works fine, unless the application fails to start because of bad information in the properties file, at which point we output information to std err and System.exit(<not zero>).
Though we haven't created any loggers at this point, log4j2 is outputting this when we access std err: ERROR StatusLogger No Log4j 2 configuration file found. Using default configuration (logging only errors to the console), or user programmatically provided configurations. Set system property 'log4j2.debug' to show Log4j 2 internal initialization logging. See https://logging.apache.org/log4j/2.x/manual/configuration.html for instructions on how to configure Log4j 2 I've gotten around that by putting in a default "dummy" log4j2.xml file: --- begin --- <?xml version="1.0" encoding="UTF-8"?> <!-- This dummy file is used only to keep log4j2 from outputting an error message about "no configuration found" in the cases that [...] --> <Configuration status="WARN"> <Appenders> <Console name="Console" target="SYSTEM_OUT"> <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/> </Console> </Appenders> <Loggers> <Root level="error"> <AppenderRef ref="Console"/> </Root> </Loggers> </Configuration> --- end --- That works around the issue above, but we register a shutdown hook when starting up, and during the sys.exit call log4j2 now outputs: --- begin --- Notification-ShutdownHook WARN Unable to register Log4j shutdown hook because JVM is shutting down. Using SimpleLogger --- end --- I've moved our code that registers the shutdown hook so that it only runs after all of the properties have been validated and the logger initialized. This changes our behavior so that the hook isn't run during a failed startup, but I can live with that. I've spent a fair amount of time looking for another way to keep log4j2 quiet in the case where we abort startup and don't use a logger anyway, but am unsure what to do. Are there any better ways to tell log4j2 not to do anything until I actually initialize it and create a logger? Thanks, Bobby