You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by "Ran//-\\mir " <ra...@myway.com> on 2004/12/17 06:13:21 UTC

Problem with Log4j (Configuration)

Apologies are mine if this issue is discussed already. 
I have two different applications i-e two separate jar files (ApplicationA.jar and ApplicationB.jar).
Both use log4j for logging to separate files (A.txt and B.txt). 
Now the scenario is 
ApplicationB uses ApplicationA jar file. I have placed ApplicationA.jar and log4j.jar in WEB_INF/lib folder of ApplicationB. When ApplicationB runs, I expect to get logs in different files but unfortunately this does not happen. ApplicationA makes some logging in B.txt and ApplicationB in A.txt. Though both are using different configuration files. 
Is this normal? What is the solution to the problem?
Thanking in advance.
Amir

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

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Problem with Log4j (Configuration)

Posted by Jacob Kjome <ho...@visi.com>.
At 05:20 PM 12/18/2004 +0100, you wrote:
 >
 >Amir,
 >
 >Are A.txt and B.txt the configuration files or the files where logging
 >output goes?
 >

I'm pretty sure he means that the .txt files are his log files and since he 
has two separate configurations, he expects appA's output to go to one file 
(as it was configured in his appA config file) and he expects appB's output 
to go to separate file (as it is configured in his appB config file).  The 
problem is that there is only one config [file] per logger 
repository.  When he says "appA" and "appB", he means two jar files in the 
same application.

The answer to this is that the approach is flawed.  The way I interpret 
this is that ApplicationA.jar and ApplicationB.jar both have a log4j config 
file in their roots.  This is a bad practice as someone else may use, for 
instance, ApplicationA.jar in their app but not want to have 
ApplicationA.jar defining their logger configuration.  The problem is 
thinking that configuration is happening per/library.  It actually happens 
per logger repository which, by default, is essentially per visible 
classloader hierarchy.  If a repository selector is used, the configuration 
happens per whatever criteria the selector uses as a demarcation of logger 
repositories.  This can add complexity which is necessary at times, but 
probably not here.

Because of this, one should not distribute config files in jars.  Logging 
is for the end user, not the creator of the library.  Remove the config 
files from the libraries and use a single config file per/application.  At 
this point, it is easy to send the output of the two libraries (with 
distinct package names) to separate log files...

<appender name="File1" class="org.apache.log4j.FileAppender">
     <param name="File" value="file1.log" />
</appender>
<appender name="File2" class="org.apache.log4j.FileAppender">
     <param name="File" value="file2.log" />
</appender>

<logger name="com.mycompany.librarya" additivity="false">
     <level value="debug"/>
     <appender-ref ref="File1"/>
</logger>

<logger name="com.mycompany.libraryb" additivity="false">
     <level value="debug"/>
     <appender-ref ref="File2"/>
</logger>

<root>
    <level value="warn"/>
    <appender-ref ref="Console"/>
</root>


I hope that answers the question.

Jake

 >At 06:13 AM 12/17/2004, Ran//-\\mir wrote:
 >
 >>Apologies are mine if this issue is discussed already.
 >>I have two different applications i-e two separate jar files
 >>(ApplicationA.jar and ApplicationB.jar).
 >>Both use log4j for logging to separate files (A.txt and B.txt).
 >>Now the scenario is
 >>ApplicationB uses ApplicationA jar file. I have placed ApplicationA.jar
 >>and log4j.jar in WEB_INF/lib folder of ApplicationB. When ApplicationB
 >>runs, I expect to get logs in different files but unfortunately this does
 >>not happen. ApplicationA makes some logging in B.txt and ApplicationB in
 >>A.txt. Though both are using different configuration files.
 >>Is this normal? What is the solution to the problem?
 >>Thanking in advance.
 >>Amir
 >
 >--
 >Ceki Gülcü
 >
 >   The complete log4j manual: http://qos.ch/log4j/
 >
 >
 >
 >---------------------------------------------------------------------
 >To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
 >For additional commands, e-mail: log4j-user-help@logging.apache.org
 >
 >  


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


RE: Problem with Log4j (Configuration)

Posted by Rana Amir Bashir <ra...@espgits.com>.
well they are files where output goes And i am using different configuration
files for both.

-----Original Message-----
From: Ceki Gülcü [mailto:ceki@qos.ch]
Sent: Saturday, December 18, 2004 9:20 PM
To: Log4J Users List
Subject: Re: Problem with Log4j (Configuration)



Amir,

Are A.txt and B.txt the configuration files or the files where logging
output goes?

At 06:13 AM 12/17/2004, Ran//-\\mir wrote:

>Apologies are mine if this issue is discussed already.
>I have two different applications i-e two separate jar files
>(ApplicationA.jar and ApplicationB.jar).
>Both use log4j for logging to separate files (A.txt and B.txt).
>Now the scenario is
>ApplicationB uses ApplicationA jar file. I have placed ApplicationA.jar
>and log4j.jar in WEB_INF/lib folder of ApplicationB. When ApplicationB
>runs, I expect to get logs in different files but unfortunately this does
>not happen. ApplicationA makes some logging in B.txt and ApplicationB in
>A.txt. Though both are using different configuration files.
>Is this normal? What is the solution to the problem?
>Thanking in advance.
>Amir

--
Ceki Gülcü

   The complete log4j manual: http://qos.ch/log4j/



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Note: Kindly note that my email address has been changed to rana.amir.bashir@espgits.com


--------------------------------------------------------------------------------------------
The information transmitted (including any attachments) is intended only for
the person or entity to which it is addressed and may contain confidential
and/or privileged material. Any review, retransmission, dissemination or
other use of, or taking of any action in reliance upon this information by
persons or entities other than the intended recipient is prohibited. ESP
Global IT Systems does not guarantee that the integrity of this
communication has been maintained nor that this communication is free of
viruses, interceptions or interference. If you received this in error,
please contact the sender and delete the material. If you require general
information please email info@espgits.com

==========================================================

ESP Global IT Systems - The Software Solution Specialists
© 2004 ESP Global IT Systems. All rights reserved.

==========================================================





---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Problem with Log4j (Configuration)

Posted by Ceki Gülcü <ce...@qos.ch>.
Amir,

Are A.txt and B.txt the configuration files or the files where logging 
output goes?

At 06:13 AM 12/17/2004, Ran//-\\mir wrote:

>Apologies are mine if this issue is discussed already.
>I have two different applications i-e two separate jar files 
>(ApplicationA.jar and ApplicationB.jar).
>Both use log4j for logging to separate files (A.txt and B.txt).
>Now the scenario is
>ApplicationB uses ApplicationA jar file. I have placed ApplicationA.jar 
>and log4j.jar in WEB_INF/lib folder of ApplicationB. When ApplicationB 
>runs, I expect to get logs in different files but unfortunately this does 
>not happen. ApplicationA makes some logging in B.txt and ApplicationB in 
>A.txt. Though both are using different configuration files.
>Is this normal? What is the solution to the problem?
>Thanking in advance.
>Amir

-- 
Ceki Gülcü

   The complete log4j manual: http://qos.ch/log4j/



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org