Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

log4j in Tomcat and Glassfish

 
Kris Massey
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic