2

Which setting do I specify in Tomcat so that I can pick a particular log4j.xml file?

I have a development and production log4j.xml file, so I'd like to be able to configure when to use one over the other.

Kevin Meredith
  • 41,036
  • 63
  • 209
  • 384

1 Answers1

3

Add in your Tomcat config the following line:

TOMCAT_OPTS="-Dlog4j.configuration=/my/config/log4j.properties"

In your development environment you can override the default settings with this, and package your production config with the war.

Of course, if there are more properties in that variable, you must keep them :)

gaborsch
  • 15,408
  • 6
  • 37
  • 48
  • besides using the env var `TOMCAT_OPTS,` how would I specify which log4j.xml to use? Is it typically specified in `web.xml` or another config file? – Kevin Meredith Feb 07 '13 at 16:09
  • 2
    Maybe you could read this article: http://stackoverflow.com/questions/2716824/where-how-does-log4j-look-for-a-log4j-properties-file or that article: http://stackoverflow.com/questions/1140358/how-to-initialize-log4j-properly – gaborsch Feb 07 '13 at 17:32