logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dominik Psenner" <dpsen...@gmail.com>
Subject RE: log4net RollingLogFileAppender: is this possible to set limit for TOTAL size of all log files?
Date Mon, 24 Sep 2012 09:42:38 GMT
Hi Kelly,

Configured like this the total maximum size of all log files should be
around 5MB * 10, which is somewhat like 50MB. Scaling either the size of a
single logfile (maximumFileSize) or the number of logfiles
(maxSizeRollBackups) by 2 should bring you to your 100MB, doesn't it?

Cheers

>-----Original Message-----
>From: KellyLynch [mailto:glen@tut.by]
>Sent: Monday, September 24, 2012 11:16 AM
>To: log4net-user@logging.apache.org
>Subject: log4net RollingLogFileAppender: is this possible to set limit for
>TOTAL size of all log files?
>
>
>In my .NET application I use log4net with the following configuration:
>
><configuration>
>    <configSections>
>        <section name="log4net"
>           type="log4net.Config.Log4NetConfigurationSectionHandler,
>log4net"
>/>
>    </configSections>
>    <log4net>
><appender name="RollingLogFileAppender"
>type="log4net.Appender.RollingFileAppender">
>  <lockingModel type="log4net.Appender.FileAppender+MinimalLock"/>
>  <file value="logs\" />
>  <datePattern value="yyyy-MM-dd.lo\g"/>
>  <staticLogFileName value="false" />
>  <appendToFile value="true" />
>  <countDirection value="1"/>
>  <rollingStyle value="Composite" />
>  <maxSizeRollBackups value="10" />
>  <maximumFileSize value="5MB" />
>  <layout type="log4net.Layout.PatternLayout">
>    <conversionPattern value="%date [%thread] %-5level %logger
>[%property{NDC}] - %message%newline" />
>  </layout>
></appender>
>
>        <root>
>            <level value="ALL" />
>            <appender-ref ref="RollingLogFileAppender" />
>        </root>
>    </log4net>
></configuration>
>
>
>
>It produces a set of log files like the following:
>2012-09-24.log.0
>2012-09-24.log.1
>...
>2012-09-24.log.10
>
>This is ALMOST what I want. The final thing I want is: to set a limit by
>total size of ALL the log files in the given location (folder). In other
>words - if total size of all the log files in the given location exceeds,
>say, 100MB, the oldest file will be removed; does not matter does the file
>belong to current day or to some day in the past. To the moment the .config
>above provides a different logic: limit by size of all the log files in the
>current GROUP (in my case the 'group' is 'current day').
>
>Can I have RollingLogFileAppender working the way I want?
>
>--
>View this message in context: http://old.nabble.com/log4net-
>RollingLogFileAppender%3A-is-this-possible-to-set-limit-for-TOTAL-size-of-
>all-log-files--tp34471537p34471537.html
>Sent from the Log4net - Users mailing list archive at Nabble.com.



Mime
View raw message