This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

log4j error

 
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?
 
author
Posts: 3281
8
Mac OS X Eclipse IDE Java
  • 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
Posts: 3281
8
Mac OS X Eclipse IDE Java
  • 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....
 
You may have just won ten million dollars! Or, maybe a tiny ad.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!