[jboss-user] [Beginners Corner] - log4j: loggin to different files + sheduler
Anna_Lut
do-not-reply at jboss.com
Fri Feb 8 10:47:02 EST 2008
I have pack: mypack.myclass
in jboss(3.2.1) I configure 2 shedulers, which call myclass method but with different parameters (parameters define log4j category for this sheduler)
scheduler-service.xml :
| <mbean code="org.jboss.varia.scheduler.Scheduler" name=":service=Scheduler1">
| ...
| <attribute name="SchedulableClass">mypack.myclass</attribute>
| <attribute name="SchedulableArguments">paramValue1</attribute>
| <attribute name="SchedulableArgumentTypes">java.lang.String</attribute>
| ....
| </mbean>
|
| <mbean code="org.jboss.varia.scheduler.Scheduler" name=":service=Scheduler2">
| ...
| <attribute name="SchedulableClass">mypack.myclass</attribute>
| <attribute name="SchedulableArguments">paramValue2</attribute>
| <attribute name="SchedulableArgumentTypes">java.lang.String</attribute>
| ....
| </mbean>
|
In mypack.myclass constructor I initialize log4j category, depending on input parameter:
| public class myclass{
| protected static Logger log;
|
| public myclass(String log4jcategory) {
| log = Logger.getLogger(log4jCategory);
| }
| ....
| }
|
in file all\conf\log4j.xml I describe this two categories:
| <appender name="LOG1" class="org.jboss.logging.appender.DailyRollingFileAppender">
| ....
| </appender>
| <appender name="LOG2" class="org.jboss.logging.appender.DailyRollingFileAppender">
| ....
| </appender>
|
| <category name="paramValue1">
| <appender-ref ref="LOG1"/>
| ...
| </category>
|
| <category name="paramValue2">
| <appender-ref ref="LOG2"/>
| ...
| </category>
|
But as a result, when sheduler starts .... from the begining log4j puts logdata into 2 different files, but at the 3-d itteration of sheduler all data writes to one file. And this one file choose randomly.
Why logdata is writtn to one log?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4127868#4127868
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4127868
More information about the jboss-user
mailing list