Hi there,

I am working on server which used thread pool to process each client request
by separate dedicated thread.

My intention is each thread ( of thread pool ) should have its own logger
and hence all client processed by that thread must be logged in
corresponding thread specific logger, that is I wanted to maintain logger
object as much as threads present.

My problem is that logger merging log content with other logger content, for
example sometime logger for thread 5 wirtes log in file for thread 8 and so
on .....

I am creating and configuring logger at run time using code specified as
below.

Is there any thing I am missing in code ????

I am using log4j-1.2.8 on windows and java's executor server for thread
pooling. 

My server having 64 threads ( ie 64 logger ) and it is running on "8 core"
machine, is this a problem as it is hightly multithreaded ????

I confirm that server creates exactly 64 logger but its containts are
interfering with different logger file.



code variables: 

sLoggerName : Current thread name ( Thread.currentThread.getName() ) 

m_sFilePath : log file path

m_sExt : log file extention

m_layout : static layout object 

............................................................... Code
.................................................


public static final Logger getLogger( final String sLoggerName )throws
IOException
{

  final Logger logger = LogManager.exists(sLoggerName);

        if(logger != null)
        {

            return logger;

        }

          Logger newLogger = LogManager.getLogger(sLoggerName);

        //Logger is not exists so create appender for logger

        String sFileName = m_sFilePath + sLoggerName + m_sExt;

        RollingFileAppender appender = new RollingFileAppender(m_layout,
sFileName, true );

        appender.setMaxBackupIndex( m_iMaxBufferIndex );

        appender.setMaxFileSize( m_sLogMaxFileSize );

        newLogger.addAppender( appender );

        newLogger.setLevel( m_logLevel );

        newLogger.setAdditivity(false);

       return newLogger;

}


.....................................................log4j.property ( for
root logger )................................................

# Category Configuration

log4j.rootLogger=INFO,Konsole,Roll

# Console Appender Configuration

log4j.appender.Konsole=org.apache.log4j.ConsoleAppender

log4j.appender.Konsole.layout=org.apache.log4j.PatternLayout

# Date Format based on ISO*8601 : %d

log4j.appender.Konsole.layout.ConversionPattern=%d [%t] %5p %c * %m%n

# Roll Appender Configuration

log4j.appender.Roll=org.apache.log4j.RollingFileAppender

log4j.appender.Roll.File=D\:/4YsClient/Log/ErrorFileList.log

log4j.appender.Roll.MaxFileSize=100MB

log4j.appender.Roll.MaxBackupIndex=10

log4j.appender.Roll.layout=org.apache.log4j.PatternLayout

# Date Format based on ISO*8601 : %d

log4j.appender.Roll.layout.ConversionPattern=%d [%t] %p (%F:%L) * %m%n


................................................................................

your help will makes me happy.



-- 
View this message in context: 
http://www.nabble.com/log4j-logger-writing-log-in-wrong-files-tp22097143p22097143.html
Sent from the Log4j - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to