Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

log4j error  RSS feed

 
Will White
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We are using log4j and most times it works fine. Sometimes when the war file is deployed on a tomcat 5.5.23 server, a message is shown. log4j:WARN No appenders could be found for logger. When that happens the log information is not written to the file. The log4j.properties file is in the war file under WEB-INF\classes. The log4j.properties file contains these lines:

log4j.defaultInitOverride = false
# Set root category priority to WARN and set its only appender to dest1.
log4j.rootLogger=DEBUG, dest1, dest2

# dest1 writes to system console.
log4j.appender.dest1=org.apache.log4j.ConsoleAppender
log4j.appender.dest1.layout=org.apache.log4j.PatternLayout
log4j.appender.dest1.layout.ConversionPattern=[%d{MMM-dd HH:mm}] %-5p %c{1} - %m%n

# dest2 writes to file.
log4j.appender.dest2=org.apache.log4j.DailyRollingFileAppender
log4j.appender.dest2.file=/var/log/tomcat5/eCMP.log
log4j.appender.dest2.datePattern='.'yyyy-MM-dd
log4j.appender.dest2.append=true
log4j.appender.dest2.layout=org.apache.log4j.PatternLayout
log4j.appender.dest2.layout.ConversionPattern=[%d{MMM-dd HH:mm}] %-5p %c{1} - %m%n

Does anyone have any suggestions?
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Will and welcome to Javaranch!

Will White wrote:We are using log4j and most times it works fine. Sometimes when the war file is deployed on a tomcat 5.5.23 server, a message is shown. log4j:WARN No appenders could be found for logger. When that happens the log information is not written to the file. The log4j.properties file is in the war file under WEB-INF\classes.


So it _does_ work sometimes and not others? Have you discovered a pattern of failure?

Will White wrote:
The log4j.properties file contains these lines:

log4j.defaultInitOverride = false
# Set root category priority to WARN and set its only appender to dest1.
log4j.rootLogger=DEBUG, dest1, dest2


Comment != configuration

Will White wrote:
# dest1 writes to system console.
log4j.appender.dest1=org.apache.log4j.ConsoleAppender
log4j.appender.dest1.layout=org.apache.log4j.PatternLayout
log4j.appender.dest1.layout.ConversionPattern=[%d{MMM-dd HH:mm}] %-5p %c{1} - %m%n


Even when it complains of no appender, are you seeing console logging?

Will White wrote:
# dest2 writes to file.
log4j.appender.dest2=org.apache.log4j.DailyRollingFileAppender
log4j.appender.dest2.file=/var/log/tomcat5/eCMP.log
log4j.appender.dest2.datePattern='.'yyyy-MM-dd
log4j.appender.dest2.append=true
log4j.appender.dest2.layout=org.apache.log4j.PatternLayout
log4j.appender.dest2.layout.ConversionPattern=[%d{MMM-dd HH:mm}] %-5p %c{1} - %m%n

Does anyone have any suggestions?


Does that location always exist with the correct permissions?

That's all I can think of right now
 
Will White
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Martijn. We have not discovered any pattern to when it fails. Every few months we have a new version of the web application that we deploy and it fails 30% of the time. We can restart tomcat and that seem to fix it and the log files are created. Therefore, I believe the permissions are fine for creating the files in the folder /var/log/tomcat5/ The console logging does not happen either when the error message shows up.
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Will,

From what I understand you initially hot deploy and only bounce Tomcat when the logs don't work? I wonder if this is a straight Tomcat bug....
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!