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 Rob Richardson <RD...@rad-con.com> on 2011/11/28 14:56:55 UTC

Why does this configuration file give me rotation by date instead of by file size?

Greetings!

I originally wrote an application to use rotating files that rotated by date, but log4net has a long-standing unfixed bug that prevents cleaning up old dated log files, and our customer is not willing to accept log files that grow without bound.  Therefore, I tried to change the configuration file to get it to rotate by size instead of date.  But it doesn't work; the log file still rotates by date.  Can someone please tell me what I have to do to get my log file to rotate by size?

(I just noticed that I'm referencing a non-existent appender in this log file.  I doubt that that is the problem.)

Thank you for your help.

RobR


<?xml version="1.0" encoding="utf-8"?>
<log4net>
  <appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
    <threhold value="DEBUG" />
    <file value="TrendMasterCAtest.log" />
    <appendToFile value="true" />
    <maximumFileSize value="1MB" />
    <maxSizeRollBackups value="5" />

    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date - %message%newline" />
    </layout>
  </appender>


      <root>
            <level value="DEBUG" />
    <appender-ref ref="RollingFile" />
    <appender-ref ref ="EventLogger" />
 </root>

</log4net>


From: Andrew Arnott [mailto:andrewarnott@gmail.com]
Sent: Sunday, November 27, 2011 2:35 PM
To: log4net-user
Subject: ThreadLogicalContext not actually following logical threads

I'm trying to use log4net.LogicalThreadContext.Stacks[stackName].Push(value) to push context onto the logical thread.  But I can see that ThreadPool.QueueUserWorkItem, and other ways that the .NET CallContext is propagated do not actually receive the log4net.LogicalThreadContext, and as a result these other threads don't have any stack inherited from the context that spawned it.

I am successfully using CallContext.LogicalSetData myself for other logical thread tracking purposes in my application so I have reason to believe it works -- I just don't know why log4net isn't working.  Any ideas?

Thanks.

--
Andrew Arnott
"I [may] not agree with what you have to say, but I'll defend to the death your right to say it." - S. G. Tallentyre


Re: Why does this configuration file give me rotation by date instead of by file size?

Posted by Pascal ROZE <pa...@gmail.com>.
Hi

Try adding this node:

<rollingStyle value="Size" />



On 28 November 2011 14:56, Rob Richardson <RD...@rad-con.com> wrote:

>  Greetings!****
>
> ** **
>
> I originally wrote an application to use rotating files that rotated by
> date, but log4net has a long-standing unfixed bug that prevents cleaning up
> old dated log files, and our customer is not willing to accept log files
> that grow without bound.  Therefore, I tried to change the configuration
> file to get it to rotate by size instead of date.  But it doesn’t work; the
> log file still rotates by date.  Can someone please tell me what I have to
> do to get my log file to rotate by size?****
>
> ** **
>
> (I just noticed that I’m referencing a non-existent appender in this log
> file.  I doubt that that is the problem.)****
>
> ** **
>
> Thank you for your help.****
>
> ** **
>
> RobR****
>
> ** **
>
> ** **
>
> <?xml version="1.0" encoding="utf-8"?>****
>
> <log4net>****
>
>   <appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
> ****
>
>     <threhold value="DEBUG" />****
>
>     <file value="TrendMasterCAtest.log" />****
>
>     <appendToFile value="true" />****
>
>     <maximumFileSize value="1MB" />****
>
>     <maxSizeRollBackups value="5" />****
>
> ** **
>
>     <layout type="log4net.Layout.PatternLayout">****
>
>       <conversionPattern value="%date - %message%newline" />****
>
>     </layout>****
>
>   </appender>****
>
> ** **
>
> ** **
>
>       <root>****
>
>             <level value="DEBUG" />****
>
>     <appender-ref ref="RollingFile" />****
>
>     <appender-ref ref ="EventLogger" />****
>
>  </root>   ****
>
> ** **
>
> </log4net>****
>
> ** **
>
> ** **
>
> *From:* Andrew Arnott [mailto:andrewarnott@gmail.com]
> *Sent:* Sunday, November 27, 2011 2:35 PM
> *To:* log4net-user
> *Subject:* ThreadLogicalContext not actually following logical threads****
>
> ** **
>
> I'm trying to use
> log4net.LogicalThreadContext.Stacks[stackName].Push(value) to push context
> onto the logical thread.  But I can see that ThreadPool.QueueUserWorkItem,
> and other ways that the .NET CallContext is propagated do not actually
> receive the log4net.LogicalThreadContext, and as a result these other
> threads don't have any stack inherited from the context that spawned it.**
> **
>
> ** **
>
> I am successfully using CallContext.LogicalSetData myself for other
> logical thread tracking purposes in my application so I have reason to
> believe it works -- I just don't know why log4net isn't working.  Any ideas?
> ****
>
> ** **
>
> Thanks.****
>
> ** **
>
> --
> Andrew Arnott
> "I [may] not agree with what you have to say, but I'll defend to the death
> your right to say it." - S. G. Tallentyre****
>
> ** **
>