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 Karel Kral <kr...@volny.cz> on 2007/02/15 12:52:26 UTC

RollingFileAppender: date based roll

Hello, is there any possibility to configure RollingFileAppender
(configured to roll every day) to use directory name based on current date?

I wish to log to 2007-02-15\test.log.2007-02-15

I have tested solution based on PatternString in file element (see
bellow), but it is not functional. The fileName pattern is parsed
exactly at program start and it never changes if program is running
through midnight.

<appender name="FileAppender" type="log4net.Appender.RollingFileAppender">
   <file value="%date{yyyy-MM-dd}\test.log"
type="log4net.Util.PatternString"/>
      <appendToFile value="true" />
      <rollingStyle value="Date" />
      <datePattern value=".yyyy-MM-dd" />
-- 
---------
Prostredi: VB.NET, VS2005 Pro, XP Pro/P4 3GHz, 2GB RAM
___________________________________________________
Karel Kral, vyvojar
ANETE, s.r.o.
___________________________________________________

RE: RollingFileAppender: date based roll

Posted by wang junwei <ke...@hotmail.com>.
I think you will have to implement your own one after checking the source 
code. Actually I've seen someone has done such functionality somewhere.


>From: Karel Kral <kr...@volny.cz>
>Reply-To: "Log4NET User" <lo...@logging.apache.org>
>To: Log4NET User <lo...@logging.apache.org>
>Subject: RollingFileAppender: date based roll
>Date: Thu, 15 Feb 2007 12:52:26 +0100
>
>Hello, is there any possibility to configure RollingFileAppender
>(configured to roll every day) to use directory name based on current 
date?
>
>I wish to log to 2007-02-15\test.log.2007-02-15
>
>I have tested solution based on PatternString in file element (see
>bellow), but it is not functional. The fileName pattern is parsed
>exactly at program start and it never changes if program is running
>through midnight.
>
><appender name="FileAppender" type="log4net.Appender.RollingFileAppender">
>    <file value="%date{yyyy-MM-dd}\test.log"
>type="log4net.Util.PatternString"/>
>       <appendToFile value="true" />
>       <rollingStyle value="Date" />
>       <datePattern value=".yyyy-MM-dd" />
>--
>---------
>Prostredi: VB.NET, VS2005 Pro, XP Pro/P4 3GHz, 2GB RAM
>___________________________________________________
>Karel Kral, vyvojar
>ANETE, s.r.o.
>___________________________________________________

_________________________________________________________________
享用世界上最大的电子邮件系统― MSN Hotmail。  http://www.hotmail.com