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 Beth Hechanova <bh...@imsco-us.com> on 2010/07/13 01:46:14 UTC

Forcing a log rollover

I'm using log4net and configure my application log via an xml configuration file.  The configuration file sets my appender to be of type "log4net.Appender.RollingFileAppender" with the following attributes:

-          'lockingModel' as minimal

-          'appendToFile' as true

-          'rollingStyle' as size

-          'maximumFIleSize' as 100KB

-          'maxSizeRollBackups as 1

I have a situation in my application where I would like to force a backup of the log file to be made when requested, as opposed to just when the maximumFileSize is reached.

Is it possible to do this programmatically?  I could not find an API that looked like it would allow a backup to be made on demand.
I'm using log4net-1.2.10, including the dll under the net 2.0 directory.  My application is written in .net 3.5 and will run on a Windows XP system.

Any pointers would be greatly appreciated.
Thanks,
Beth





__________________________________________________________________

This email and any files transmitted with it are confidential & proprietary to Systems and
Software Enterprises, Inc. (dba IMS). This information is intended solely for the use of
the individual or entity to which it is addressed. Access or transmittal of the information
contained in this e-mail, in full or in part, to any other organization or persons is not
authorized.

__________________________________________________________________






Re: Forcing a log rollover

Posted by Yuriy Taraday <yo...@gmail.com>.
Hello.

You should override
AdjustFileBeforeAppend<http://logging.apache.org/log4net/release/sdk/log4net.Appender.RollingFileAppender.AdjustFileBeforeAppend.html>
method
and add some flag like "RolloverNow" which will be checked at every incoming
event.
You'll not get immediate backup, but this is easiest solution.
If immediate backup is critical, you should provide method like
"RolloverNow" that calls protected method
RollOverSize<http://logging.apache.org/log4net/release/sdk/log4net.Appender.RollingFileAppender.RollOverSize.html>
.

Kind regards, Yuriy.

On Tue, Jul 13, 2010 at 3:46 AM, Beth Hechanova <bh...@imsco-us.com>wrote:

>  I’m using log4net and configure my application log via an xml
> configuration file.  The configuration file sets my appender to be of type “
> log4net.Appender.RollingFileAppender” with the following attributes:
>
> -          ‘lockingModel’ as minimal
>
> -          ‘appendToFile’ as true
>
> -          ‘rollingStyle’ as size
>
> -          ‘maximumFIleSize’ as 100KB
>
> -          ‘maxSizeRollBackups as 1
>
>
>
> I have a situation in my application where I would like to force a backup
> of the log file to be made when requested, as opposed to just when the
> maximumFileSize is reached.
>
>
>
> Is it possible to do this programmatically?  I could not find an API that
> looked like it would allow a backup to be made on demand.
>
> I’m using log4net-1.2.10, including the dll under the net 2.0 directory.
> My application is written in .net 3.5 and will run on a Windows XP system.
>
>
>
> Any pointers would be greatly appreciated.
>
> Thanks,
>
> Beth
>
>
>
>
>
>
>
> __________________________________________________________________
>
> This email and any files transmitted with it are confidential & proprietary
> to Systems and
> Software Enterprises, Inc. (dba IMS). This information is intended solely
> for the use of
> the individual or entity to which it is addressed. Access or transmittal of
> the information
> contained in this e-mail, in full or in part, to any other organization or
> persons is not
> authorized.
>
> __________________________________________________________________
>
>
>
>
>
>