A case of classpath roulette :-) Would you mind filing a Jira issue for better validation/messaging? https://issues.apache.org/jira/projects/LOG4J2
I've written similar validation for slf4j bindings elsewhere that we may be able to leverage (though the general case has many edge cases that I haven't thought through yet): /** * Validate that there is only one slf4j binding present. If there are multiple distinct bindings logging will * disappear into the void depending on classpath order. */ private static void validateSlf4jBindings() { try { List<URL> slf4jBindings = Collections.list( getClassLoader().getResources("org/slf4j/impl/StaticLoggerBinder.class")); if (slf4jBindings.size() > 1) { String message = "Detected multiple Slf4j bindings: " + slf4jBindings; // Write to standard streams, if the exception is caught and logged, it may not be recorded. System.err.println(message); throw new IllegalStateException(message); } } catch (IOException e) { throw new IllegalStateException("Failed to discover slf4j bindings", e); } } On Fri, Oct 9, 2020, at 10:25, Michiel Graat wrote: > Thanks for your answer but that wasn't the problem. In the end there was a > stray log4j 1.x JAR still in the application artifact, after removing that > everything worked fine. This wasn't clear from Log4J2's own debug logging, > according to that everything was fine. I don't know why this kind of > classpath problem (which I guess it is) doesn't lead to visible log errors. > Ah well, all is well that ends well! > > Kind regards, > > Michiel > > -----Original Message----- > From: Eric Schwarzenbach <subscri...@blackbrook.org> > Sent: Tuesday, 6 October 2020 18:06 > To: log4j-user@logging.apache.org > Subject: Re: Logging works fine on one machine but not on the other > > I'm sure you know this but a reminder just in case this slipped by, since > it's easy to not notice at a glance: the path separator character needs to be > different between the Windows and Linux (; vs :) > > On 10/6/20 11:47 AM, Michiel Graat wrote: > > Hi all, > > > > I am in the process of migrating an application from Log4J 1.2.16 to Log4J > > 2.13.3. I am using the log4j 1.2 to 2.13.3 bridge for this purpose. > > > > I am almost done and on my own development machine everything is working > > perfectly. However, when I deploy the application to a test server all the > > logging gets send to the root logger only. The log4j2.xml configuration > > files on both machines are exactly the same, only the paths differ. Also: > > my development machine runs Windows, the test server runs Linux. I have > > added the one on the test server to the end of this e-mail, excuse the > > messy replace statement. Some extra information: the application runs on > > Weblogic 12.2.1.3. > > > > On my own machine I added the location of the log4j2.xml to the classpath. > > On the test server I have tried adding the location to the classpath as > > well as setting it through the log4j.configurationFile Java VM parameter. > > The result in both cases is the same: all the logfiles are created at > > startup but only the one mentioned in the root logger gets logdata send to > > it, the other logfiles stay empty. This tells me that at least Log4J2 is > > able to find and read the configuration file. I have tried switching the > > appender which is mentioned in the root logger. In that case logging data > > gets send to that file, so it does not seem to be anything filesystem > > related. > > > > I am completely lost here and do not know what is going wrong, hence this > > e-mail. Any ideas? > > > > Kind regards, > > > > Michiel > > > > <?xml version="1.0" encoding="UTF-8" ?> <Configuration > > monitorInterval="60"> > > <Appenders> > > <RollingFile name="ERROR_LOG" fileName="/var/log/weblogic/app/error.log" > > filePattern="/var/log/weblogic/app/error.log%d{yyyy-MM-dd}.gz"> > > <PatternLayout charset="UTF-8" pattern="###%d{yyyy-MM-dd HH:mm:ss,SSS > > Z}{Europe/Amsterdam}|%d{yyyy-MM-dd HH:mm:ss,SSS > > Z}{UTC}|%-5p|%t|%c{2}|%replace{%replace{%replace{%m}{(<[^/]*?[wW]achtwoord.*?>).*?(</.*?[wWWachtwoord].*?>)}{$1********$2}}{(<pw>).*?(</pw>)}{$1********$2}}{(<newPW>).*?(</newPW>)}{$1********$2}|%n" > > /> > > <Policies> > > <TimeBasedTriggeringPolicy interval="1"/> > > </Policies> > > <DefaultRolloverStrategy max="7"/> > > </RollingFile> > > <RollingFile name="DEBUG_LOG" fileName="/var/log/weblogic/app/debug.log" > > filePattern="/var/log/weblogic/app/debug.log%d{yyyy-MM-dd}.gz"> > > <PatternLayout charset="UTF-8" pattern="###%d{yyyy-MM-dd HH:mm:ss,SSS > > Z}{Europe/Amsterdam}|%d{yyyy-MM-dd HH:mm:ss,SSS > > Z}{UTC}|%-5p|%t|%c{2}|%replace{%replace{%replace{%m}{(<[^/]*?[wW]achtwoord.*?>).*?(</.*?[wWWachtwoord].*?>)}{$1********$2}}{(<pw>).*?(</pw>)}{$1********$2}}{(<newPW>).*?(</newPW>)}{$1********$2}|%n" > > /> > > <Policies> > > <TimeBasedTriggeringPolicy interval="1"/> > > </Policies> > > <DefaultRolloverStrategy max="7"/> > > </RollingFile> > > <RollingFile name="FACADE_LOG" fileName="/var/log/weblogic/app/facade.log" > > filePattern="/var/log/weblogic/app/facade.log%d{yyyy-MM-dd}.gz"> > > <PatternLayout charset="UTF-8" pattern="###%d{yyyy-MM-dd HH:mm:ss,SSS > > Z}{Europe/Amsterdam}|%d{yyyy-MM-dd HH:mm:ss,SSS > > Z}{UTC}|%-5p|%t|%c{2}|%replace{%replace{%replace{%m}{(<[^/]*?[wW]achtwoord.*?>).*?(</.*?[wWWachtwoord].*?>)}{$1********$2}}{(<pw>).*?(</pw>)}{$1********$2}}{(<newPW>).*?(</newPW>)}{$1********$2}|%n" > > /> > > <Policies> > > <TimeBasedTriggeringPolicy interval="1"/> > > </Policies> > > <DefaultRolloverStrategy max="7"/> > > </RollingFile> > > <RollingFile name="AUDIT_LOG" fileName="/var/log/weblogic/audit/audit.log" > > filePattern="/var/log/weblogic/audit/audit.log%d{yyyy-MM-dd}.gz"> > > <PatternLayout charset="UTF-8" pattern="###%d{yyyy-MM-dd HH:mm:ss,SSS > > Z}{Europe/Amsterdam}|%d{yyyy-MM-dd HH:mm:ss,SSS > > Z}{UTC}|%-5p|%t|%c{2}|%replace{%replace{%replace{%m}{(<[^/]*?[wW]achtwoord.*?>).*?(</.*?[wWWachtwoord].*?>)}{$1********$2}}{(<pw>).*?(</pw>)}{$1********$2}}{(<newPW>).*?(</newPW>)}{$1********$2}|%n" > > /> > > <Policies> > > <TimeBasedTriggeringPolicy interval="1"/> > > </Policies> > > <DefaultRolloverStrategy max="7"/> > > </RollingFile> > > </Appenders> > > <Loggers> > > <Logger name="nl.sidn.app.facade" level="debug" additivity="false"> > > <AppenderRef ref="FACADE_LOG"/> > > </Logger> > > <Logger name="nl.sidn.app.auditadapter" level="debug" additivity="false"> > > <AppenderRef ref="AUDIT_LOG"/> > > </Logger> > > <Logger name="nl.sidn.app.proces" level="debug" additivity="false"> > > <AppenderRef ref="DEBUG_LOG"/> > > </Logger> > > <Root level="debug"> > > <AppenderRef ref="ERROR_LOG" /> > > </Root> > > </Loggers> > > </Configuration> > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: mailto:log4j-user-unsubscr...@logging.apache.org > > For additional commands, e-mail: mailto:log4j-user-h...@logging.apache.org > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: mailto:log4j-user-unsubscr...@logging.apache.org > For additional commands, e-mail: mailto:log4j-user-h...@logging.apache.org > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org > For additional commands, e-mail: log4j-user-h...@logging.apache.org >