logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Madhu Gowda <madhu.gowd...@yahoo.com>
Subject using RollingFileAppender
Date Mon, 02 Jun 2008 12:13:08 GMT
Hi all,
&nbsp;
I am trying to make use of RollingFileAppender.
My code is as follows:
&nbsp;
LoggerPtr logger( Logger::getLogger("CustomLogger"));
&nbsp;
RollingFileAppender *pAppender = new RollingFileAppender();
pAppender-&gt;setName( log4cxx::helpers::Transcoder::decode("TestAppender"));
pAppender-&gt;setFile( log4cxx::helpers::Transcoder::decode("TestLogFile.txt"));
pAppender-&gt;setAppend( true);
pAppender-&gt;setMaxBackupIndex( 5);
pAppender-&gt;setMaxFileSize( log4cxx::helpers::Transcoder::decode("5 KB"));
pAppender-&gt;setLayout( new PatternLayout( log4cxx::helpers::Transcoder::decode("%d [%t]
%-5p %c - %l - %m%n")));
&nbsp;
logger-&gt;addAppender( fAppender);
&nbsp;
This code is giving&nbsp;the error as:
"No output stream or file set for the appender named TestAppender"
&nbsp;
But, if I create the appender as:
&nbsp;
RollingFileAppender *pAppender = new RollingFileAppender( new PatternLayout( log4cxx::helpers::Transcoder::decode("%d
%-5p %c - %l - %m%n")),
&nbsp;log4cxx::helpers::Transcoder::decode("TestLogFile.txt"));
&nbsp;
and I&nbsp;set the&nbsp;MaxBackupIndex and MaxFileSize as follows:&nbsp;
&nbsp;
pAppender-&gt;setMaxBackupIndex( 5);
pAppender-&gt;setMaxFileSize( log4cxx::helpers::Transcoder::decode("5 KB"));
&nbsp;
It works fine but, the new log file is not getting created after the MaxFileSize (5 KB) is
reached, the log messages are just getting appended to same log file ().
&nbsp;
Please, suggest what is going wrong here.
&nbsp;
Thanks &amp; Regards,
Madhu Gowda
&nbsp;


      
Mime
View raw message