tags:

views:

214

answers:

3

Hello all,

I am new to log4j but I've been reading for almost an hour, and I dont know how to solve this.

I have a jar file A which uses log4j and writes logs to the console and to a file.

I also have a java project, which uses external jar A. If the java project doesnt use log4j, then I can see the logs by A when running the java project in the console and in the file.

But if I want to use lof4j in the java project, then log file by jar module A is now not created, why? do i have to write any special configuration in lof4j.properties file for module A or the java project? thanks!

+1  A: 

Only one configuration file will be used, the one in your calling project.

Its configuration has to correspond to all logs you want, wether they are in the main project or in a jar.

KLE
KLE's right. More help would be possible if you included your log4j.properties.
Jim Downing
+1  A: 

I am confused by java project "using log4j", since the java project requires jar A, the project is implicitly using log4j whether or not the project makes direct log4j calls. Anyway to answer your question, try specifying log4j.properties (a log4j configuration file) in command line, eg. -Dlog4j.configuration=log4j.properties and set the root category to CONSOLE where CONSOLE is the name of a ConsoleAppender.

Murali VP
I think by a project that uses jar A "not using log4j" he means the project that is using jar A does not have its own log4j configuration (so jar A's configuration is getting used).
ColinD
A: 

Thank you both, that is what I wanted to know!

Joaquin