You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-user@logging.apache.org by LECHNER Martin <Ma...@frequentis.com> on 2006/05/23 17:05:26 UTC

Question: MaxBackupIndex RollinfIleappender XML config Howto

I try to figure aut how to configure the MaxBackupIndex property with an xml
config file.
 
The file looks like below and it does not work.
Any suggestions?
 
 
  <appender name="RootFileApp" class="RollingFileAppender">
    <param name="File" value="log_root.txt" />
    <param name="append" value="false" />
    <param name="MaxBackupIndex" value="5" />
    <triggeringPolicy class="org.apache.log4j.SizeBasedTriggeringPolicy">
      <param name="MaxFileSize" value="10KB"/>
    </triggeringPolicy>
    <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern"  value="%d[%t] %-5p %c %x - %m %n"/>
    </layout>
  </appender>

Best regards
ML

AW: Question: MaxBackupIndex RollinfIleappender XML config Howto

Posted by LECHNER Martin <Ma...@frequentis.com>.
Just tested it - seems to work perfectly.
Thanks a lot for your help!
 
ML

________________________________

Von: Arunkumar [mailto:aviswanathan@appsecinc.com]
Gesendet: Mi 24.05.2006 17:20
An: 'Log4CXX User'
Betreff: RE: Question: MaxBackupIndex RollinfIleappender XML config Howto



Hi Martin,

This is a file that I used to test the rolling file appender and it worked.
I used one of the unit test xml input files and modified it.
Replace the values as per your requirements. Also replace
testcxxlogging.level2.l2r and testcxxlogging.level2.l2r.c1 with your logger
names. I defined these loggers in a parent and child class respectively.

-Arun

<?xml version="1.0" encoding="UTF-8" ?>

<log4j:configuration xmlns:log4j='http://logging.apache.org/' debug="true">

  <appender name="ROLLING"
class="org.apache.log4j.rolling.RollingFileAppender">
    <rollingPolicy
class="org.apache.log4j.rolling.FixedWindowRollingPolicy">
       <param name="fileNamePattern" value="filterBased-test.%i.log"/>
       <param name="minIndex" value="0"/>       
         <param name="maxIndex" value="3" />
    </rollingPolicy>
       
        <triggeringPolicy
class="org.apache.log4j.SizeBasedTriggeringPolicy">
                <param name="MaxFileSize" value="2KB"/>    
        </triggeringPolicy>

        <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%m%n"/>
    </layout>
    <param name="file" value="filterBased-test.log"/>
    <param name="append" value="true"/>

  </appender>

  <logger name="testcxxlogging.level2.l2r" additivity="true">
    <appender-ref ref="ROLLING"/>
    <level value="info"/>
  </logger>

  <logger name="testcxxlogging.level2.l2r.c1" additivity="false">
    <appender-ref ref="ROLLING"/>
    <level value="warn"/>
  </logger>

</log4j:configuration>

________________________________________
From: log4cxx-user-return-1568-aviswanathan=appsecinc.com@logging.apache.org
[mailto:log4cxx-user-return-1568-aviswanathan=appsecinc.com@logging.apache.o
rg] On Behalf Of LECHNER Martin
Sent: Wednesday, May 24, 2006 7:02 AM
To: Log4CXX User
Subject: AW: Question: MaxBackupIndex RollinfIleappender XML config Howto

 
Unfortuantely the configuration does not work.
I still get 7 backup files (seems to be the default in
FixedWindowRollingPolicy)
 
Is there still an error in the config file?
 
best regards
ML
 
 
 
 
 






RE: Question: MaxBackupIndex RollinfIleappender XML config Howto

Posted by Arunkumar <av...@appsecinc.com>.
Hi Martin,

This is a file that I used to test the rolling file appender and it worked.
I used one of the unit test xml input files and modified it.
Replace the values as per your requirements. Also replace
testcxxlogging.level2.l2r and testcxxlogging.level2.l2r.c1 with your logger
names. I defined these loggers in a parent and child class respectively.

-Arun

<?xml version="1.0" encoding="UTF-8" ?>

<log4j:configuration xmlns:log4j='http://logging.apache.org/' debug="true">

  <appender name="ROLLING"
class="org.apache.log4j.rolling.RollingFileAppender">
    <rollingPolicy
class="org.apache.log4j.rolling.FixedWindowRollingPolicy">
       <param name="fileNamePattern" value="filterBased-test.%i.log"/>
       <param name="minIndex" value="0"/>	 
	 <param name="maxIndex" value="3" />
    </rollingPolicy>
	
	<triggeringPolicy
class="org.apache.log4j.SizeBasedTriggeringPolicy">
		<param name="MaxFileSize" value="2KB"/>	    
	</triggeringPolicy>

	<layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%m%n"/>
    </layout>
    <param name="file" value="filterBased-test.log"/>
    <param name="append" value="true"/>

  </appender>

  <logger name="testcxxlogging.level2.l2r" additivity="true">
    <appender-ref ref="ROLLING"/>
    <level value="info"/>
  </logger>

  <logger name="testcxxlogging.level2.l2r.c1" additivity="false">
    <appender-ref ref="ROLLING"/>
    <level value="warn"/>
  </logger>

</log4j:configuration>

________________________________________
From: log4cxx-user-return-1568-aviswanathan=appsecinc.com@logging.apache.org
[mailto:log4cxx-user-return-1568-aviswanathan=appsecinc.com@logging.apache.o
rg] On Behalf Of LECHNER Martin
Sent: Wednesday, May 24, 2006 7:02 AM
To: Log4CXX User
Subject: AW: Question: MaxBackupIndex RollinfIleappender XML config Howto

 
Unfortuantely the configuration does not work. 
I still get 7 backup files (seems to be the default in
FixedWindowRollingPolicy)
 
Is there still an error in the config file?
 
best regards
ML
 
 
 
 
 




AW: Question: MaxBackupIndex RollinfIleappender XML config Howto

Posted by LECHNER Martin <Ma...@frequentis.com>.
 
Unfortuantely the configuration does not work. 
I still get 7 backup files (seems to be the default in
FixedWindowRollingPolicy)
 
Is there still an error in the config file?
 
best regards
ML
 
 
 

 

 





Re: Question: MaxBackupIndex RollinfIleappender XML config Howto

Posted by Curt Arnold <ca...@apache.org>.
On May 23, 2006, at 10:05 AM, LECHNER Martin wrote:

> I try to figure aut how to configure the MaxBackupIndex property  
> with an xml
> config file.
>
> The file looks like below and it does not work.
> Any suggestions?
>
>
>   <appender name="RootFileApp" class="RollingFileAppender">
>     <param name="File" value="log_root.txt" />
>     <param name="append" value="false" />
>     <param name="MaxBackupIndex" value="5" />
>     <triggeringPolicy  
> class="org.apache.log4j.SizeBasedTriggeringPolicy">
>       <param name="MaxFileSize" value="10KB"/>
>     </triggeringPolicy>
>     <layout class="org.apache.log4j.PatternLayout">
>       <param name="ConversionPattern"  value="%d[%t] %-5p %c %x - % 
> m %n"/>
>     </layout>
>   </appender>
>
> Best regards
> ML
> <winmail.dat>


log4cxx implements the log4j 1.3 style rolling file appender (that is  
org.apache.log4j.rolling.RollingFileAppender vs  
org.apache.log4j.RollingFileAppender).  We haven't reworked the XML  
configuration reader so it could support two different classes with  
name that differ only in package name.

Your configuration file looks like a mix of o.a.l.RFA configuration  
and o.a.l.r.RFA configuration.  MaxBackupIndex is used by o.a.l.RFA  
and triggeringPolicy by o.a.l.r.RFA.

Unfortunately, there is not a test in either log4j or log4cxx that  
contains an example of setting up a size based o.a.l.r.RFA.  I think  
this sample is closer (and likely works for log4j), but I haven't  
tested it with log4cxx.

   <appender name="RootFileApp"  
class="org.apache.log4j.rolling.RollingFileAppender">
     <rollingPolicy  
class="org.apache.log4j.rolling.FixedWindowRollingPolicy">
        <param name="maxIndex" value="5"/>
     </rollingPolicy>
     <triggeringPolicy  
class="org.apache.log4j.SizeBasedTriggeringPolicy">
       <param name="MaxFileSize" value="10KB"/>
   </triggeringPolicy>
   <layout class="org.apache.log4j.PatternLayout">
       <param name="ConversionPattern"  value="%d[%t] %-5p %c %x - %m  
%n"/>
     </layout>
     <param name="file" value="log_root.txt"/>
     <param name="append" value="false"/>
   </appender>