File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "log4j in Tomcat and Glassfish" Watch "log4j in Tomcat and Glassfish" New topic

log4j in Tomcat and Glassfish

Kris Massey

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 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

Kris Massey

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
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

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
I agree. Here's the link:
subject: log4j in Tomcat and Glassfish
It's not a secret anymore!