logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nicko Cadell" <ni...@neoworks.com>
Subject RE: RollingFileAppender: log files with constant extension and composite name
Date Sun, 13 Nov 2005 18:42:37 GMT
> I'd like current messages to always be logged into a file 
> with the same name (e.g., mylogs.log).  

To do this you need to set the file property to the 'static' log file
name, and set the staticLogFileName property to true, e.g.:

<file value="C:\\ProphIT_CTI\\mylogs.log" />
<staticLogFileName value="true" />

> When a file hits a 
> maximum size I'd like to have the file renamed and have 
> future logs go into a new file with the same name as before 
> (i.e., mylogs.log). 

This will happen if the staticLogFileName is set to true and the
rollingStyle is Size or Composite.

> The old file would be renamed to a name 
> that includes a sequence number and date (e.g., 
> mylogs20051109.2.log for today's second log file). It would 
> be OK if the date didn't get added to the name until the next day.
> The RollingFileAppender does this fine except that the 
> sequence number becomes the file extension.

Currently the sequence number must be the last part of the filename,
otherwise the appender cannot identify the previously rolled files.


> Is there a way to configure the RollingFileAppender to do this?
> I'm currently using the following configuration: 
>     <appender name="Dev4RollingFile" 
> type="log4net.Appender.RollingFileAppender">
>       <file value="C:\\ProphIT_CTI" />
>       <maximumFileSize value="500KB" />
>       <maxSizeRollBackups value="5" />
>       <datePattern value="yyyy-MM-dd'.log'" />
>       <staticLogFileName value="false" />
>       <rollingStyle value="Composite" />
>      <appendToFile value="true" />
>       <countDirection value="0" />
>       <layout type="log4net.Layout.XmlLayoutSchemaLog4j" />
>     </appender>
> Thanks.
> --
> Mike Blake-Knox 

View raw message