Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to move old log files, from a log4net RollingLogFileAppender into a different folder?

Tags:

c#

.net

log4net

I have a rolling file appender configured with this:

<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
  <file value="appname" />
  <appendToFile value="true" />
  <rollingStyle value="Composite" />
  <datePattern value="'.'yyyyMMdd'.log'" />
  <maxSizeRollBackups value="30" />
  <maximumFileSize value="10MB" />
  <staticLogFileName value="false" />
  <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
  </layout>
</appender>

This works fine, but I was wondering if there was a way to move the old log files into an "archive" folder, instead of having them moved to the same folder?

like image 318
Karma_Police Avatar asked Mar 22 '10 15:03

Karma_Police


People also ask

Where are log4net logs stored?

You can configure the log4net. config file to create log files. The file is located in the webroot\App_data directory of the installation. The different log files are described in Services logs.

What is RollingFileAppender in log4net?

RollingFileAppender can roll log files based on size or date or both depending on the setting of the RollingStyle property. When set to Size the log file will be rolled once its size exceeds the MaximumFileSize.

Does log4net create directory?

When using a file appender, the destination folder does not have to exist. Log4net creates the folder. Using an administrator account, connect to the Coveo Master server.


1 Answers

You can always open RollingLogFileAppender.cs and modify it to anything you want. It's open source, mate. And this class is really easy to extend. Personally I hate its naming style for log files, and I have my own RollingLogFileAppender to please me. :)

like image 105
Lex Li Avatar answered Oct 22 '22 18:10

Lex Li