Search code examples
log4jslf4jearwebsphere-8

Websphere 8.5.3, SLF4j Log4j, Multiple EARs, multiple log files not generating


I have two EARs deployed to Websphere 8.5.3 with different log4j configurations. But the server is only generating one log file. If I deploy the EARs individually, the server is generating the log file , but when both the EARs are deployed only one log file is being generated by the server. I have the slf4j-log4j jars on the class path and one lo4j.properties in each EAR's WAR module. Can anyone please help me understand whats going on with the Websphere JVM or if I am doing something wrong

log4j.rootLogger=INFO
log4j.logger.com.code.first=INFO,appOne
log4j.appender.appOne=org.apache.log4j.RollingFileAppender
log4j.appender.appOne.Name=ApplicationLogAppender
log4j.appender.appOne.File=/logPath/AppOneLog.log
log4j.appender.appOne.layout=org.apache.log4j.PatternLayout
log4j.appender.appOne.MaxFileSize=10MB
log4j.appender.appOne.MaxBackupIndex=10
log4j.appender.appOne.layout.ConversionPattern=%d %-5p %t - %m%n
log4j.appender.appOne.Threshold=DEBUG
log4j.appender.appOne.Append=false


log4j.rootLogger=INFO
log4j.logger.com.code.second=INFO,appTwo
log4j.appender.appTwo=org.apache.log4j.RollingFileAppender
log4j.appender.appTwo.Name=ApplicationLogAppender
log4j.appender.appTwo.File=/logPath/AppTwolog.log
log4j.appender.appTwo.layout=org.apache.log4j.PatternLayout
log4j.appender.appTwo.MaxFileSize=10MB
log4j.appender.appTwo.MaxBackupIndex=10
log4j.appender.appTwo.layout.ConversionPattern=%d %-5p %t - %m%n
log4j.appender.appTwo.Threshold=DEBUG
log4j.appender.appTwo.Append=false

Solution

  • This:

    I have the slf4j-log4j jars on the class path

    Does that mean the same log4j JAR is shared between the applications? There may be a problem that the log4j classes are loaded just once and shared between the applications. Can you try putting the log4j JAR in each web module WEB-INF/lib folder? That will give each of the web modules its own load of the log4j classes and may resolve the problem. (Also, since log4j classes are also used by the server, make sure to have the web modules load classes from themselves first.)

    Thomas Bitonti, IBM WebSphere Application Server Development