logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Radovan Raszka" <ras...@hasam.cz>
Subject RE: Date Rollover filename
Date Tue, 21 Sep 2010 06:15:48 GMT
Please notice, that <file value="..\\Data\\Logs\\debug" /> _doesn't_ contain extension.
 
Your config should be like this:
    <appender name="Root" type="log4net.Appender.RollingFileAppender">

                <file value="c:/log/synch/root" />

                <appendToFile value="true" />

                <maxSizeRollBackups value="10" />

                <datePattern value="yyyy-MM-dd.txt" />

                <rollingStyle value="Date" />

                <staticLogFileName value="false" />

                <layout type="log4net.Layout.PatternLayout">

                                <header value="[Header]&#xD;&#xA;"/>

                                <footer value="[Footer]&#xD;&#xA;"/>

                                <conversionPattern value="%date [%thread] %-5level %logger
(%file:%line) - %message%newline" />

                </layout>

    </appender>

 
Now log files will have names in form root2010-09-21.txt (for today's date)
Radovan

________________________________

Od: David Gerler [mailto:dgerler@gmail.com] 
Odesláno: 20. září 2010 20:32
Komu: 'Log4NET User'
Předmět: RE: Date Rollover filename



Michael,

   Other than still having the .txt in the middle of the file name, it works nicely. Well
enough for our use in fact.

 

Chris,

   Do you have an example of how to use it? I tried:

 

    <appender name="Root" type="log4net.Appender.RollingFileAppender">

                <file value="c:/log/synch/root.txt" />

                <appendToFile value="true" />

                <maxSizeRollBackups value="10" />

                <PreserveLogFileNameExtension value="true">

                <datePattern value="yyyy-MM-dd" />

                <rollingStyle value="Date" />

                <staticLogFileName value="true" />

                <layout type="log4net.Layout.PatternLayout">

                                <header value="[Header]&#xD;&#xA;"/>

                                <footer value="[Footer]&#xD;&#xA;"/>

                                <conversionPattern value="%date [%thread] %-5level %logger
(%file:%line) - %message%newline" />

                </layout>

    </appender>

 

From: Lansdaal, Michael T [mailto:michael.t.lansdaal@boeing.com] 
Sent: Monday, September 20, 2010 1:00 PM
To: log4net-user@logging.apache.org
Subject: RE: Date Rollover filename

 

Yes - you need to set the datePattern value for the appender.  Something like this

 

<appender name="RollingDebugLogFileAppender" type="log4net.Appender.RollingFileAppender">
   <file value="..\\Data\\Logs\\debug" />
   <appendToFile value="true" />
   <rollingStyle value="Composite" />
   <staticLogFileName value="false" />
   <datePattern value=".yyyy-MM-dd.lo\g" />

and you would set yours to

   <datePattern value=".yyyy-MM-dd.txt" />

Hope this helps.

________________________________

From: David Gerler [mailto:dgerler@gmail.com] 
Sent: Monday, September 20, 2010 10:23 AM
To: log4net-user@logging.apache.org
Subject: Date Rollover filename

We are using the Date rollover style for our logs. The thing we don't like is the fact that
it appends the date to the end of the filename like "root.txt20100920". We'd like to have
it insert the date in the middle like "root20100920.txt". Is that possible?

 

I have searched the documentation and can't seem to find anything. I also tried inserting
[%date] in the filename in the config file, but that didn't work.


Mime
View raw message