Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
The moose likes Other JSE/JEE APIs and the fly likes log4j in Tomcat and Glassfish Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Badass: Making Users Awesome this week in the Game Development forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "log4j in Tomcat and Glassfish" Watch "log4j in Tomcat and Glassfish" New topic
Author

log4j in Tomcat and Glassfish

Kris Massey
Greenhorn

Joined: Mar 26, 2009
Posts: 12
Hey guys Im new to log4j and was hoping I could get a quick bit of help...

Ive got the following log4j.properties file



Im trying to use the TOMCAT_HOME environment variable to locate the logs folder...Im not sure if this is the correct way to do things or not for a start. However Ive tried using just test.log and no log file is being created...Ive setup an stdout logger and that works so I know the file is being read but for some reason this lest.log doesnt get created....

Can anyone help me out as its driving me mad and I know it should be easy to correct but for some reason I just cant get it right

Cheers
Kris
Kris Massey
Greenhorn

Joined: Mar 26, 2009
Posts: 12
Forgot to mention that later Im going to include this in an ear file so any pointers on getting it to work with glassfish would also be great!

So a bit more detail as I think this is a likely cause of the problem but Im new to both OSX and log4j...would I need to alter the permissions on the logs foler inside of tomcat? I assumed that as the webapp is running within tomcat it wouldnt need to be altered but I could be mistaken
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
log4j doesn't pick up environment variables, does let you use system properties.

Syntax to use system property, if LOG_HOME were one:


system property on command-line looks like this (standalone java, NOT tomcat):


Tomcat may already have some system property you can use, I don't remember. Take a look at the log4j short manual, search for TOMCAT_OPTS to see how they suggested setting a different property.
Kris Massey
Greenhorn

Joined: Mar 26, 2009
Posts: 12
Thanks that helped...there is a variable you can used which Ive added below in case anyone stumbles across this and needs the answer



Cheers for the guidance
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: log4j in Tomcat and Glassfish