Log4j Problem with Multiple Application

T

the.cagatay

Hi,

I have 5 different java applications(one has main method, others are
threads) which uses log4j for logging purpose. The mechanism which is
used for to run the programs, is
A manager application starts the other applications. Each application
has its own log4j configuration file with different names.
I put root logger descreption for every file of the applications.
The manager does not have logger.
//////////////////////////////////////////////////////////////////
<root>
<priority value="DEBUG" />
<appender-ref ref="App1Appender" />
</root>

<root>
<priority value="DEBUG" />
<appender-ref ref="App2Appender" />
</root>

<root>
<priority value="DEBUG" />
<appender-ref ref="App3Appender" />
</root>

<root>
<priority value="DEBUG" />
<appender-ref ref="App4Appender" />
</root>
//////////////////////////////////////////////////////////////////

But When I did this, App1 and App2 applications did not log. I try to
remove root logger from some of the files that only one file will have
root logger description. At this point I get the error
//////////////////////////////////////////////////////////////////
log4j: No appenders could be found for category (some.category.name).
log4j: Please initialize the log4j system properly.
//////////////////////////////////////////////////////////////////
I know I must declare root loger to solve this problem but when I put
the root logger declaration to every file, some of the loggers do not
log.

In summary, I have 5 applications which have different log4j xml
configuration file. And I want each of them to be configured according
to the given file and logs correctly.
Could you suggest something to solve this problem.
Thanks :)
 
B

Bob Kranson

I recall theres a default log4j.properties configuration in the log4j
archive. You might want to look into that or use some of the command line
options of log4j to initialize your applications. Sounds like your
applications are properly isolated but maybe the classloader of the given
application server is losing track of which root it read last; or possible
using the included log4j default settings. Surely I read a 'comprehensive'
log4j settings post out on the 'net. Maybe just make a category for each
application to have more granular control in the long run....

HTH
Bob Kranson
 
G

gimme_this_gimme_that

This log4j.xml file sets the root log level to error and sets the log
level for
com.something to debug :

<?xml version="1.0"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration>

<appender name="FileLog" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ABSOLUTE} %5p %c{1}:%L -
%m%n"/>
</layout>
</appender>

<category name="com.something">
<priority value="debug" />
</category>

<root>
<priority value ="error" />
<appender-ref ref="FileLog"/>
</root>

</log4j:configuration>
 
Joined
Jun 17, 2011
Messages
2
Reaction score
0
Hi,

I have 5 different java applications(one has main method, others are
threads) which uses log4j for logging purpose. The mechanism which is
used for to run the programs, is
A manager application starts the other applications. Each application
has its own log4j configuration file with different names.
I put root logger descreption for every file of the applications.
The manager does not have logger.
//////////////////////////////////////////////////////////////////
<root>
<priority value="DEBUG" />
<appender-ref ref="App1Appender" />
</root>

<root>
<priority value="DEBUG" />
<appender-ref ref="App2Appender" />
</root>

<root>
<priority value="DEBUG" />
<appender-ref ref="App3Appender" />
</root>

<root>
<priority value="DEBUG" />
<appender-ref ref="App4Appender" />
</root>
//////////////////////////////////////////////////////////////////

But When I did this, App1 and App2 applications did not log. I try to
remove root logger from some of the files that only one file will have
root logger description. At this point I get the error
//////////////////////////////////////////////////////////////////
log4j: No appenders could be found for category (some.category.name).
log4j: Please initialize the log4j system properly.
//////////////////////////////////////////////////////////////////
I know I must declare root loger to solve this problem but when I put
the root logger declaration to every file, some of the loggers do not
log.

In summary, I have 5 applications which have different log4j xml
configuration file. And I want each of them to be configured according
to the given file and logs correctly.
Could you suggest something to solve this problem.
Thanks :)
Hi

Did you got success for this :

I have 5 applications which have different log4j xml
configuration file. And I want each of them to be configured according
to the given file and logs correctly.
Could you suggest something to solve this problem.
 
Joined
Jun 17, 2011
Messages
2
Reaction score
0
Different log4j xml

Did you got any success for it?

I have 5 applications which have different log4j xml
configuration file. And I want each of them to be configured according
to the given file and logs correctly.
Could you suggest something to solve this problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,992
Messages
2,570,220
Members
46,805
Latest member
ClydeHeld1

Latest Threads

Top