1

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?

2
  • is this answer helpful? stackoverflow.com/questions/1140358/… Commented Feb 27, 2012 at 2:58
  • Actually I don't want to do it in the Java commandline...I would prefer a way to include it in the java program. Commented Feb 27, 2012 at 4:17

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

Comments

1

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.

2 Comments

Yes, what I am asking is how to tell log4j to look for a different place for the properties file. I think if we include the directory into the classpath it would be fine, but I don't want to do it as a run option for "Java".
Call System.setProperty before initializing any loggers.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.