tags:

views:

63

answers:

3

I was thinking to use log4j for my standalone java project. Is it possible to use it for java project(not a web app).

If its possible then how should I be able to initialize the properties file and where should I put the properties file(directory structure).

Any help is appreciated.

A: 

It's definitly possible to use log4j in a standalone project. Just set your classpath to include the log4j jar. As for the properties file, the apache documentation should say where to log4j looks for it (it's probably also configurable).

carnold
+3  A: 

Yes, it is possible, we do it all the time. You just need a log4j.properties file on your classpath, which in most cases means in the base directory of your jar file. If you wish to have multiple properties files with differing configurations, you can create a properties configurator in some entry point before your first logging statement.

Brian M. Carr
+1  A: 

Yes it's possible.

If you're planning to create a jar file.

  • Make sure that your log4j.properties is found in your classes folder in jar file.
  • Make sure that your log4j jar is included in your classpath.

Enjoy!

The Elite Gentleman