• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 292
  • Last Modified:

can't get log4j to start in tomcat6

I followed the instructions in
http://tomcat.apache.org/tomcat-6.0-doc/logging.html

tried using ${catalina.home}/lib and ${catalina.home}/shared/lib for the jar and .properties file.

log4j.properties looks like this
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

### direct messages to file hibernate.log ###
log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.File=${catalina.home}/logs/tomcat.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

### set log levels - for more verbose logging change 'info' to 'debug' ###

log4j.rootLogger=warn, stdout

#log4j.logger.org.hibernate=error
log4j.logger.org.hibernate=error

tomcat.log file is never created. any body see anything wrong?
0
bhomass
Asked:
bhomass
  • 7
  • 5
1 Solution
 
blackfrancis75Commented:
change

log4j.rootLogger=warn, stdout

to


log4j.rootLogger=warn,stdout,file
0
 
bhomassAuthor Commented:
I tried that,

I also tried using explicit file path,

then i tried moving the properties file and log4j lib to the application lib dir.

in all case i can not get the tomcat.log file to be generated!

what else can be wrong?

it all works inside eclipse. is there some additional thing I need to do in deployment to kick start log4j?
0
 
blackfrancis75Commented:
whereabouts in your project/source tree have you placed log4j.properties ?  it should be in the root of your /src directory, and Eclipse should copy it into WEB-INF/classes when it compiles.  Check that this is working.  Most important is that a copy of the file ends up in WEB-INF/classes
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
bhomassAuthor Commented:
it is there for sure.
0
 
blackfrancis75Commented:
Where in your code have you put loging statements?  Are you logging anything during statup of your app?
Also, are there any exceptions in Tomcat's own logs?
0
 
bhomassAuthor Commented:
I have Logger.getLogger(class) all over the place. these produce good output in eclipse.

nothing notable in tomcat logs.
0
 
blackfrancis75Commented:
I'm a little confused.  What do you mean by getting logging statements 'in Eclipse'?  Isn't this a web-app?
0
 
blackfrancis75Commented:
Do you mean the Console logger is working, but not the File logger?
0
 
blackfrancis75Commented:
can you post your current lo4j.properties as it is now?
0
 
blackfrancis75Commented:
if ${catalina.home} can't be determined, the path will be determines relative to the Eclipse installation directory - so try making (or checking) a /logs directory in the Eclipse installation directory
0
 
bhomassAuthor Commented:
I switched to logback. it worked instantly.

although I still don't know what went wrong with my log4j set up, I would like to award you the points for staying with me.
0
 
bhomassAuthor Commented:
real bug still unknown
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 7
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now