You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by cyz <zh...@micron.com> on 2011/01/14 05:28:58 UTC

RollingFileAppender

Hi, I'd like to have a logging system with below behaviors, is
RollingFileAppender able to achieve?
1> messages are logged to a fixed file name, say log.txt.
2> log files are auto backup by sizes. I.e. when log.txt hits the configured
size, it's renamed as logyyMMddHHmmss.txt, next message coming in will be
written to log.txt again.
3> there is no limit on how many files can be backup.

Thank you.
-- 
View this message in context: http://old.nabble.com/RollingFileAppender-tp30668883p30668883.html
Sent from the Log4net - Users mailing list archive at Nabble.com.


Re: RollingFileAppender

Posted by cyz <zh...@micron.com>.
I realized that as well after I went through the RollingFileAppender code :(.
Have already started to write my own appender.... Thank you.



Michael Schall wrote:
> 
> Re-reading your exact requirements, I'm not sure you can get exactly what
> you want with the built in appenders. 
> 
> The current RollingFileAppender roles on size changing the log count
> portion of the file name and on date changing the date portion. I think
> you would need to write your own appender if you want to change the date
> when size rolls the file. 
> 
> Mike
> 
> On Jan 16, 2011, at 8:48 PM, cyz <zh...@micron.com> wrote:
> 
>> 
>> Hi, do you mind to provide an example? I played around with the Composite
>> setting, but didn't get what I really want.
>> 
>> 
>> Michael Schall wrote:
>>> 
>>> http://logging.apache.org/log4net/release/config-examples.html
>>> 
>>> <http://logging.apache.org/log4net/release/config-examples.html>Looks
>>> like
>>> you want to have a rollingStyle="Composite"
>>> 
>>> On Fri, Jan 14, 2011 at 12:01 AM, cyz <zh...@micron.com> wrote:
>>> 
>>>> 
>>>> Tried the configuration, but the backup file name is still log.txt.1,
>>>> log.txt.2, doesn't append with datetime as specified in DatePattern
>>>> 
>>>> 
>>>> Jim Scott-8 wrote:
>>>>> 
>>>>> Try this
>>>>> 
>>>>> <appender name="RollingFileAppender"
>>>>> type="log4net.Appender.RollingFileAppender">
>>>>> <file value="log.txt" />
>>>>> <appendToFile value="true" />
>>>>> <rollingStyle value="Size" />
>>>>> <maxSizeRollBackups value="-1" />
>>>>> <maximumFileSize value="10MB" />
>>>>> <staticLogFileName value="true" />
>>>>> <countDirection value="0" />
>>>>> 
>>>>> <layout type="log4net.Layout.PatternLayout">
>>>>> <conversionPattern value="%date [%thread] %-5level %logger
>>>>> [%property{NDC}] - %message%newline" />
>>>>> </layout>
>>>>> </appender>
>>>>> 
>>>>> On 1/13/2011 8:28 PM, cyz wrote:
>>>>>> Hi, I'd like to have a logging system with below behaviors, is
>>>>>> RollingFileAppender able to achieve?
>>>>>> 1>  messages are logged to a fixed file name, say log.txt.
>>>>>> 2>  log files are auto backup by sizes. I.e. when log.txt hits the
>>>>>> configured
>>>>>> size, it's renamed as logyyMMddHHmmss.txt, next message coming in
>>>>>> will
>>>> be
>>>>>> written to log.txt again.
>>>>>> 3>  there is no limit on how many files can be backup.
>>>>>> 
>>>>>> Thank you.
>>>>> 
>>>>> 
>>>> 
>>>> --
>>>> View this message in context:
>>>> http://old.nabble.com/RollingFileAppender-tp30668883p30669112.html
>>>> Sent from the Log4net - Users mailing list archive at Nabble.com.
>>>> 
>>>> 
>>> 
>>> 
>> 
>> -- 
>> View this message in context:
>> http://old.nabble.com/RollingFileAppender-tp30668883p30676167.html
>> Sent from the Log4net - Users mailing list archive at Nabble.com.
>> 
> 
> 
:-((:-((:-((
-- 
View this message in context: http://old.nabble.com/RollingFileAppender-tp30668883p30698364.html
Sent from the Log4net - Users mailing list archive at Nabble.com.


Re: RollingFileAppender

Posted by Michael Schall <mi...@gmail.com>.
Re-reading your exact requirements, I'm not sure you can get exactly what you want with the built in appenders. 

The current RollingFileAppender roles on size changing the log count portion of the file name and on date changing the date portion. I think you would need to write your own appender if you want to change the date when size rolls the file. 

Mike

On Jan 16, 2011, at 8:48 PM, cyz <zh...@micron.com> wrote:

> 
> Hi, do you mind to provide an example? I played around with the Composite
> setting, but didn't get what I really want.
> 
> 
> Michael Schall wrote:
>> 
>> http://logging.apache.org/log4net/release/config-examples.html
>> 
>> <http://logging.apache.org/log4net/release/config-examples.html>Looks like
>> you want to have a rollingStyle="Composite"
>> 
>> On Fri, Jan 14, 2011 at 12:01 AM, cyz <zh...@micron.com> wrote:
>> 
>>> 
>>> Tried the configuration, but the backup file name is still log.txt.1,
>>> log.txt.2, doesn't append with datetime as specified in DatePattern
>>> 
>>> 
>>> Jim Scott-8 wrote:
>>>> 
>>>> Try this
>>>> 
>>>> <appender name="RollingFileAppender"
>>>> type="log4net.Appender.RollingFileAppender">
>>>> <file value="log.txt" />
>>>> <appendToFile value="true" />
>>>> <rollingStyle value="Size" />
>>>> <maxSizeRollBackups value="-1" />
>>>> <maximumFileSize value="10MB" />
>>>> <staticLogFileName value="true" />
>>>> <countDirection value="0" />
>>>> 
>>>> <layout type="log4net.Layout.PatternLayout">
>>>> <conversionPattern value="%date [%thread] %-5level %logger
>>>> [%property{NDC}] - %message%newline" />
>>>> </layout>
>>>> </appender>
>>>> 
>>>> On 1/13/2011 8:28 PM, cyz wrote:
>>>>> Hi, I'd like to have a logging system with below behaviors, is
>>>>> RollingFileAppender able to achieve?
>>>>> 1>  messages are logged to a fixed file name, say log.txt.
>>>>> 2>  log files are auto backup by sizes. I.e. when log.txt hits the
>>>>> configured
>>>>> size, it's renamed as logyyMMddHHmmss.txt, next message coming in will
>>> be
>>>>> written to log.txt again.
>>>>> 3>  there is no limit on how many files can be backup.
>>>>> 
>>>>> Thank you.
>>>> 
>>>> 
>>> 
>>> --
>>> View this message in context:
>>> http://old.nabble.com/RollingFileAppender-tp30668883p30669112.html
>>> Sent from the Log4net - Users mailing list archive at Nabble.com.
>>> 
>>> 
>> 
>> 
> 
> -- 
> View this message in context: http://old.nabble.com/RollingFileAppender-tp30668883p30676167.html
> Sent from the Log4net - Users mailing list archive at Nabble.com.
> 

Re: RollingFileAppender

Posted by cyz <zh...@micron.com>.
Hi, do you mind to provide an example? I played around with the Composite
setting, but didn't get what I really want.


Michael Schall wrote:
> 
> http://logging.apache.org/log4net/release/config-examples.html
> 
> <http://logging.apache.org/log4net/release/config-examples.html>Looks like
> you want to have a rollingStyle="Composite"
> 
> On Fri, Jan 14, 2011 at 12:01 AM, cyz <zh...@micron.com> wrote:
> 
>>
>> Tried the configuration, but the backup file name is still log.txt.1,
>> log.txt.2, doesn't append with datetime as specified in DatePattern
>>
>>
>> Jim Scott-8 wrote:
>> >
>> > Try this
>> >
>> > <appender name="RollingFileAppender"
>> > type="log4net.Appender.RollingFileAppender">
>> > <file value="log.txt" />
>> > <appendToFile value="true" />
>> > <rollingStyle value="Size" />
>> > <maxSizeRollBackups value="-1" />
>> > <maximumFileSize value="10MB" />
>> > <staticLogFileName value="true" />
>> > <countDirection value="0" />
>> >
>> > <layout type="log4net.Layout.PatternLayout">
>> > <conversionPattern value="%date [%thread] %-5level %logger
>> > [%property{NDC}] - %message%newline" />
>> > </layout>
>> > </appender>
>> >
>> > On 1/13/2011 8:28 PM, cyz wrote:
>> >> Hi, I'd like to have a logging system with below behaviors, is
>> >> RollingFileAppender able to achieve?
>> >> 1>  messages are logged to a fixed file name, say log.txt.
>> >> 2>  log files are auto backup by sizes. I.e. when log.txt hits the
>> >> configured
>> >> size, it's renamed as logyyMMddHHmmss.txt, next message coming in will
>> be
>> >> written to log.txt again.
>> >> 3>  there is no limit on how many files can be backup.
>> >>
>> >> Thank you.
>> >
>> >
>>
>> --
>> View this message in context:
>> http://old.nabble.com/RollingFileAppender-tp30668883p30669112.html
>> Sent from the Log4net - Users mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://old.nabble.com/RollingFileAppender-tp30668883p30676167.html
Sent from the Log4net - Users mailing list archive at Nabble.com.


Re: RollingFileAppender

Posted by Michael Schall <mi...@gmail.com>.
http://logging.apache.org/log4net/release/config-examples.html

<http://logging.apache.org/log4net/release/config-examples.html>Looks like
you want to have a rollingStyle="Composite"

On Fri, Jan 14, 2011 at 12:01 AM, cyz <zh...@micron.com> wrote:

>
> Tried the configuration, but the backup file name is still log.txt.1,
> log.txt.2, doesn't append with datetime as specified in DatePattern
>
>
> Jim Scott-8 wrote:
> >
> > Try this
> >
> > <appender name="RollingFileAppender"
> > type="log4net.Appender.RollingFileAppender">
> > <file value="log.txt" />
> > <appendToFile value="true" />
> > <rollingStyle value="Size" />
> > <maxSizeRollBackups value="-1" />
> > <maximumFileSize value="10MB" />
> > <staticLogFileName value="true" />
> > <countDirection value="0" />
> >
> > <layout type="log4net.Layout.PatternLayout">
> > <conversionPattern value="%date [%thread] %-5level %logger
> > [%property{NDC}] - %message%newline" />
> > </layout>
> > </appender>
> >
> > On 1/13/2011 8:28 PM, cyz wrote:
> >> Hi, I'd like to have a logging system with below behaviors, is
> >> RollingFileAppender able to achieve?
> >> 1>  messages are logged to a fixed file name, say log.txt.
> >> 2>  log files are auto backup by sizes. I.e. when log.txt hits the
> >> configured
> >> size, it's renamed as logyyMMddHHmmss.txt, next message coming in will
> be
> >> written to log.txt again.
> >> 3>  there is no limit on how many files can be backup.
> >>
> >> Thank you.
> >
> >
>
> --
> View this message in context:
> http://old.nabble.com/RollingFileAppender-tp30668883p30669112.html
> Sent from the Log4net - Users mailing list archive at Nabble.com.
>
>

Re: RollingFileAppender

Posted by cyz <zh...@micron.com>.
Tried the configuration, but the backup file name is still log.txt.1,
log.txt.2, doesn't append with datetime as specified in DatePattern


Jim Scott-8 wrote:
> 
> Try this
> 
> <appender name="RollingFileAppender" 
> type="log4net.Appender.RollingFileAppender">
> <file value="log.txt" />
> <appendToFile value="true" />
> <rollingStyle value="Size" />
> <maxSizeRollBackups value="-1" />
> <maximumFileSize value="10MB" />
> <staticLogFileName value="true" />
> <countDirection value="0" />
> 
> <layout type="log4net.Layout.PatternLayout">
> <conversionPattern value="%date [%thread] %-5level %logger 
> [%property{NDC}] - %message%newline" />
> </layout>
> </appender>
> 
> On 1/13/2011 8:28 PM, cyz wrote:
>> Hi, I'd like to have a logging system with below behaviors, is
>> RollingFileAppender able to achieve?
>> 1>  messages are logged to a fixed file name, say log.txt.
>> 2>  log files are auto backup by sizes. I.e. when log.txt hits the
>> configured
>> size, it's renamed as logyyMMddHHmmss.txt, next message coming in will be
>> written to log.txt again.
>> 3>  there is no limit on how many files can be backup.
>>
>> Thank you.
> 
> 

-- 
View this message in context: http://old.nabble.com/RollingFileAppender-tp30668883p30669112.html
Sent from the Log4net - Users mailing list archive at Nabble.com.


Re: RollingFileAppender

Posted by Jim Scott <js...@infoconex.com>.
Try this

<appender name="RollingFileAppender" 
type="log4net.Appender.RollingFileAppender">
<file value="log.txt" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="-1" />
<maximumFileSize value="10MB" />
<staticLogFileName value="true" />
<countDirection value="0" />
<param name="DatePattern" value=" logyyMMddHHmmss.txt" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger 
[%property{NDC}] - %message%newline" />
</layout>
</appender>

On 1/13/2011 8:28 PM, cyz wrote:
> Hi, I'd like to have a logging system with below behaviors, is
> RollingFileAppender able to achieve?
> 1>  messages are logged to a fixed file name, say log.txt.
> 2>  log files are auto backup by sizes. I.e. when log.txt hits the configured
> size, it's renamed as logyyMMddHHmmss.txt, next message coming in will be
> written to log.txt again.
> 3>  there is no limit on how many files can be backup.
>
> Thank you.