For some reasons it is required ro use different configuration files... 


so whats the second solution of the problem?







 --- On Sat 12/18, Jacob Kjome < [EMAIL PROTECTED] > wrote:

From: Jacob Kjome [mailto: [EMAIL PROTECTED]

To: [email protected]

Date: Sat, 18 Dec 2004 11:31:45 -0600

Subject: Re: Problem with Log4j (Configuration)



At 05:20 PM 12/18/2004 +0100, you wrote:<br> ><br> >Amir,<br> ><br> >Are A.txt 
and B.txt the configuration files or the files where logging<br> >output 
goes?<br> ><br><br>I'm pretty sure he means that the .txt files are his log 
files and since he <br>has two separate configurations, he expects appA's 
output to go to one file <br>(as it was configured in his appA config file) and 
he expects appB's output <br>to go to separate file (as it is configured in his 
appB config file).  The <br>problem is that there is only one config [file] per 
logger <br>repository.  When he says "appA" and "appB", he means two jar files 
in the <br>same application.<br><br>The answer to this is that the approach is 
flawed.  The way I interpret <br>this is that ApplicationA.jar and 
ApplicationB.jar both have a log4j config <br>file in their roots.  This is a 
bad practice as someone else may use, for <br>instance, ApplicationA.jar in 
their app but not want to have <br>ApplicationA.jar defining their logger 
configuration.  The problem is <br>thinking that configuration is happening 
per/library.  It actually happens <br>per logger repository which, by default, 
is essentially per visible <br>classloader hierarchy.  If a repository selector 
is used, the configuration <br>happens per whatever criteria the selector uses 
as a demarcation of logger <br>repositories.  This can add complexity which is 
necessary at times, but <br>probably not here.<br><br>Because of this, one 
should not distribute config files in jars.  Logging <br>is for the end user, 
not the creator of the library.  Remove the config <br>files from the libraries 
and use a single config file per/application.  At <br>this point, it is easy to 
send the output of the two libraries (with <br>distinct package names) to 
separate log files...<br><br><appender name="File1" 
class="org.apache.log4j.FileAppender"><br>     <param name="File" 
value="file1.log" /><br></appender><br><appender name="File2" 
class="org.apache.log4j.FileAppender"><br>     <param name="File" 
value="file2.log" /><br></appender><br><br><logger 
name="com.mycompany.librarya" additivity="false"><br>     <level 
value="debug"/><br>     <appender-ref ref="File1"/><br></logger><br><br><logger 
name="com.mycompany.libraryb" additivity="false"><br>     <level 
value="debug"/><br>     <appender-ref 
ref="File2"/><br></logger><br><br><root><br>    <level value="warn"/><br>    
<appender-ref ref="Console"/><br></root><br><br><br>I hope that answers the 
question.<br><br>Jake<br><br> >At 06:13 AM 12/17/2004, Ran//-\\mir wrote:<br> 
><br> >>Apologies are mine if this issue is discussed already.<br> >>I have two 
different applications i-e two separate jar files<br> >>(ApplicationA.jar and 
ApplicationB.jar).<br> >>Both use log4j for logging to separate files (A.txt 
and B.txt).<br> >>Now the scenario is<br> >>ApplicationB uses ApplicationA jar 
file. I have placed ApplicationA.jar<br> >>and log4j.jar in WEB_INF/lib folder 
of ApplicationB. When ApplicationB<br> >>runs, I expect to get logs in 
different files but unfortunately this does<br> >>not happen. ApplicationA 
makes some logging in B.txt and ApplicationB in<br> >>A.txt. Though both are 
using different configuration files.<br> >>Is this normal? What is the solution 
to the problem?<br> >>Thanking in advance.<br> >>Amir<br> ><br> >--<br> >Ceki 
G�lc�<br> ><br> >   The complete log4j manual: http://qos.ch/log4j/<br> ><br> 
><br> ><br> 
>---------------------------------------------------------------------<br> >To 
unsubscribe, e-mail: [EMAIL PROTECTED]<br> >For additional commands, e-mail: 
[EMAIL PROTECTED]<br> ><br> >  
<br><br><br>---------------------------------------------------------------------<br>To
 unsubscribe, e-mail: [EMAIL PROTECTED]<br>For additional commands, e-mail: 
[EMAIL PROTECTED]<br><br>

_______________________________________________
No banners. No pop-ups. No kidding.
Make My Way your home on the Web - http://www.myway.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to