lamwaiman1988
lamwaiman1988

Reputation: 3742

How can we tell log4j where is the properties file?

I know we can put it in the home directory of the project and it works as a charm. But really I want to put it under a directory name "Conf" for convenience of later maintenance. How can we do this?

Upvotes: 1

Views: 238

Answers (2)

bmargulies
bmargulies

Reputation: 100050

I don't know about 'we', but the log4j documentation is perfectly clear.

http://logging.apache.org/log4j/1.2/manual.html will tell you that log4j searches for log4j.properties or log4j.xml in the classpath, until and unless you use a system property to tell it to look for a different file or in a different place.

You might also find http://robertmaldon.blogspot.com/2007/09/programmatically-configuring-log4j-and.html interesting as an example of explicit configuration from code; it does not use a log4j.properties At All.

Upvotes: 1

Jayan
Jayan

Reputation: 18459

log4j gives option to use different file as input. Also you can do a watch on the contents. See http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PropertyConfigurator.html#configureAndWatch(java.lang.String, long) for details

Upvotes: 2

Related Questions