The file name pattern is just a date/time format string (see
DateTimeFormatInfo), so you can't use any character in your file name
that is a valid date/time format character.  You will notice in mine
that to get a ".log" extension that I had to escape the "g" (
value=".yyyy-MM-dd.lo\\g" ), so you need to make yours look like
value=".yyyyMMdd.\\tx\\t" to get a ".txt" extension.

Thanks, Mike

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] 
Sent: Thursday, May 06, 2004 8:00 AM
To: [email protected]
Cc: Lansdaal, Michael T
Subject: RE: RollingFileAppender File Extension/Date Format


Thanks for your solution. Here is my appender and the results:

<appender name="MainLog" type="log4net.Appender.RollingFileAppender">
        <file value="Main.log" />
        <appendToFile value="true" />
        <datePattern value=".yyyyMMdd.log" />
        <rollingStyle value="Date" />
        <param name="StaticLogFileName" value="false" />
        <layout type="log4net.Layout.PatternLayout">
                <conversionPattern value="%d %-8ndc %-5thread %-5level
%logger %message %timestampms %n" />
        </layout>
</appender>

Which results in:
Main.log.20040430.loA.D

If I use <datePattern value=".yyyyMMdd.txt" /> the file name becomes
this: Main.log.20040430.AxA

Is there some sort of string replacement going on?

- Julian


-----Original Message-----
From: Lansdaal, Michael T [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 29, 2004 3:01 PM
To: [EMAIL PROTECTED]; [email protected]
Subject: RE: RollingFileAppender File Extension/Date Format


Julian - Yes, its possible.  I have a log file name format of
"debug.2004-04-26.log".  You can set this with the appender in the
config file, although, I don't think how I'm using it is quite what was
envisioned.

Here's my appender:

                <appender name="RollingLogFileAppender"
type="log4net.Appender.RollingFileAppender">
                        <param name="File" value="..\\Data\\Logs\\debug"
/>
                        <param name="AppendToFile" value="true" />
                        <param name="MaxSizeRollBackups" value="10" />
                        <param name="MaximumFileSize" value="100000" />
                        <param name="RollingStyle" value="Composite" />
                        <param name="StaticLogFileName" value="false" />
                        <param name="DatePattern"
value=".yyyy-MM-dd.lo\\g" />
                        <layout type="log4net.Layout.PatternLayout">
                                <param name="Header" value="[BEGIN_LOG
=========================]\r\n" />
                                <param name="Footer" value="[END_LOG
=========================]\r\n\r\n" />
                                <param name="ConversionPattern"
value="%d [%t] %-5p %c [%x] - %m%n" />
                        </layout>
                </appender>

Thanks, Mike Lansdaal

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] 
Sent: Thursday, April 29, 2004 2:20 PM
To: [email protected]
Subject: RollingFileAppender File Extension/Date Format


I'm not sure if this is possible with log4net, but I would like to
change RollingFileAppender so the date file suffix is something other
than the '.log' followed by the formatted date. Maybe something like
this:

LoggerFileName.YYYYMMdd.log

- or -

YYYYMMdd.LoggerFileName.log

Thanks...

Reply via email to