Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

log4j: Why aren't I seeing output in my log file?

 
Dave Alvarado
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm using Tomcat 6.0.24 and log4j 1.2.16. Nothing is appearing in my log4j logs as defined by my properties files and I was looking to get some insight as to why. Here is my log4j.properties, located in my war file's WEB-INF/classes directory ...



I'm creating the logger and using it in the code below. The System.err.println statement is printed in my catalina.out file, so I know the branch of code is being invoked ...



Any help as to why nothing is appearing in my logs is appreciated, - Dave
 
rajeev yadav
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where have you kept your log4j.properties. Also you need to initiate log4j. General way to do it initialising in a servlet which is configured in web.xml. See below link

http://www.avajava.com/tutorials/lessons/how-do-i-initialize-log4j-in-a-web-application.html


Also remember to place log4j.properties right under classes folder in output dir.
 
rajeev yadav
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can log4j.properties at any location but you need to tell your app to load it from that location
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic