Hi 

Ceki , u mean that every webapps has to be its own log file , right ? if so,
my  configuration file  has got two different categories for different two
webapps(category per webapp) so i think there will be no problem about
synchronization if i use one property file, i hope i am right :)

About Question 2 : 
for example if i have got 3 java beans in my webapp and all these 3 java
beans uses the same category for writing the log ,
can any synchronization problem  occur ?

        test__
                 |__WEB-INF__
                              |__classes__
                                         |__DovizOp.java
                                         |
                                         |__SerbestOp.java
                                         |
                                         |__IslemOp.java        

i put  " static Category cat = Category.getInstance("deneme");"   at the
beginning of  my  3 java beans .

****************************************************************************
*
import org.apache.log4j.*;
public class DovizOp {
        
        static Category cat = Category.getInstance("deneme");  
        ...................
        ....................    
}
****************************************************************************
**
import org.apache.log4j.*;
public class SerbestOp {
        
        static Category cat = Category.getInstance("deneme");  
        ...................
        ....................    
}
****************************************************************************
*
import org.apache.log4j.*;
public class IslemOp {
        
        static Category cat = Category.getInstance("deneme");  
        ...................
        ....................    
}
****************************************************************************
*



thanks 

Altug . 

-----Original Message-----
From: Ceki Gülcü [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 27, 2001 1:32 PM
To: LOG4J Users Mailing List
Subject: Re: is it dangerous


At 09:56 27.07.2001 +0300, you wrote:
>Hi all ,
>
>Question 1 = 
>i am using tomcat with this option 
>        -Dlog4j.configuration=file:/usr/local/test/log4j.properties
>
>only one configuration file for all web applications
>
>and my configuration files's content =  
>
>***************************************************************************
*
>******************
>log4j.category.deneme=INFO, logx
>log4j.additivity.deneme=false
>log4j.appender.logx=org.apache.log4j.RollingFileAppender 
>log4j.appender.logx.File=/tmp/test.log 
>log4j.appender.logx.layout.ConversionPattern=%-25d %p %-40.40c{1} %3x -
%m%n
>
>log4j.appender.logx.layout=org.apache.log4j.PatternLayout 
>log4j.appender.logx.MaxFileSize=10MB 
>log4j.appender.logx.MaxBackupIndex=1 
>
>log4j.category.deneme2=DEBUG, logy
>log4j.additivity.deneme2=false
>log4j.appender.logy=org.apache.log4j.RollingFileAppender 
>log4j.appender.logy.File=/tmp/bireysel.log 
>log4j.appender.logy.layout.ConversionPattern=%-25d %p %-40.40c{1} %3x -
%m%n
>
>log4j.appender.logy.layout=org.apache.log4j.PatternLayout 
>log4j.appender.logy.MaxFileSize=10MB 
>log4j.appender.logy.MaxBackupIndex=1 ,
>***************************************************************************
*
>******************
>
>there are two category objects  , and each my tomcat's contexts using only
>one category , 
>lets say , i have got two contexts , test1 and test and 
>java beans under test1 context uses deneme category
>java beans under test2 context uses deneme2 category , 
>is it dengerous because in the log4j document( page 12 ) it says that =
>"Thus, the same configuration file will be used for all web-applications --
>in other words, disaster waiting to happen"

Different web applications load the log4j classes from different
classloaders. Thus, appender synchronization will not work. In particular,
your rolling appender output will be messed up because multiple rolling
appenders will write to the same file without any synchronization
whatsoever. They might even roll the same file in a totally uncontrolled
fashion.

So yes. The practice of having one config file for all webapps is unsafe.  

If you want to have one config file for all your webapps, then you
parameterize the name of the output file. As in

log4j.appender.logx=org.apache.log4j.RollingFileAppender 
log4j.appender.logx.File=${testFile}

where the system property "testFile" is set differently for each of your
webapps.


>Question 2 = 
>In the test1 context , all my java beans under this context , logs the
>error's using the same category object 
>
>is it dangerous ? 

I don't understand the question.


--
Ceki Gülcü - http://qos.ch


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

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

Reply via email to