Okay,

 

I wrote a small test app so I could get this right.  Seems to have
helped as I think I understand this better now.

1.      Yes it is possible to have the appender roll the filename on the
date change
2.      Yes it is possible to specify where the appender places the date
pattern

 

If I use 

    <staticLogFileName value="false" />

Then the file name is always generated on the date roll over.

 

If I use a better date format string with a literal tacked on the end, I
get the file names I'm after.

    <datePattern value="yyyyMMdd'.log.txt'" />

 

All you need to do is modify the original file value to exclude the
original %date I was using, as the appender adds this for me.

    <file type="log4net.Util.PatternString"

          value="${ALLUSERSPROFILE}\Application Data\Job
Scheduler\%env{COMPUTERNAME}.Job Scheduler Service" />

 

Then I get the filename pattern I'm after.

myComp.Job Scheduler Service.20081121.log.txt

myComp.Job Scheduler Service.20081122.log.txt

myComp.Job Scheduler Service.20081123.log.txt

 

The only question that remains is...

Can I specify a pattern for WHERE the appender should place the suffix
of what number this is when doing a maxSizeRollBackups ??

<maxSizeRollBackups value="10" />

 

I'll keep 10 files for a given day. But the file name is coming out
as...

myComp.Job Scheduler Service.20081121.log.txt

myComp.Job Scheduler Service.20081121.log.txt.1

myComp.Job Scheduler Service.20081121.log.txt.2

myComp.Job Scheduler Service.20081121.log.txt.3

 

whereas I'd prefer

myComp.Job Scheduler Service.20081121.log.txt

myComp.Job Scheduler Service.20081121.1.log.txt

myComp.Job Scheduler Service.20081121.2.log.txt

myComp.Job Scheduler Service.20081121.3.log.txt

 

Thanks in advance if someone can help with this.

Hadley

 

________________________________

From: Hadley Willan [mailto:[EMAIL PROTECTED] 
Sent: Friday, 21 November 2008 11:05
To: Log4NET User
Subject: RollingFileAppender date pattern

 

Hi all,

 

I'm fine tuning the logging but it's not quite right...

What I want is for the file to roll at midnight to a new date pattern
file and roll within the same day if it reaches 50MB.

 

Eg.  

Start up application, 21-NOV-2008,   file gets created

myComp.Job Scheduler Service.20081121.log.txt

 

ideally, service continues to run, midnight rolls around and there's a
new file created for the 22nd and entries go to that.

myComp.Job Scheduler Service.20081122.log.txt

 

Problem is I'm not getting that... I'm getting a roll of the current
file suffixed with the starting date? And logging continues to the same
"21st" file pattern

myComp.Job Scheduler Service.20081121.log.txt <-- latest entries in here

myComp.Job Scheduler Service.20081121.log.txt20081121 <-- rolled file at
midnight.

 

I've tried setting the rollingStyle to Date or Composite, but that
hasn't worked either.

 

This is possible??

Below is the config options. I'd appreciate any help.

 

Also, I may have misinterpreted the maxSizeRollBackups...  I've assumed
that would keep 10 days worth of log files and then start deleting older
log files for me, but I'm beginning to think that only applies to the
rolls with a day?

So I'll have to clean up any log files OLDER than 10 days?

 

Thanks in advance.

Hadley

 

 

  <!-- local messages-->

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

    <file type="log4net.Util.PatternString"

          value="${ALLUSERSPROFILE}\Application Data\Job
Scheduler\%env{COMPUTERNAME}.Job Scheduler
Service.%date{yyyyMMdd}.log.txt" />

    <!-- if an existing file is there, continue and append to it -->

    <appendToFile value="true" />

    <rollingStyle value="Composite" />

    <!-- roll on a full date change, use yyyyMMdd-HH for hourly -->

    <datePattern value="yyyyMMdd" />

    <!-- keeps up to 10 of these files, for an entire DAY, IGNORE The
size  -->

    <maxSizeRollBackups value="10" />

    <!-- within a day, if the file size reaches 50MB, roll it too -->

    <!-- because it's text, Log file service will zip this down to
around 5MB  -->

    <!-- 5MB for mailing a log file is a safe size, most servers won't
bounce that -->

    <maximumFileSize value="50MB" />

    <!-- layout, including our custom property, customAssemblyName-->

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

      <conversionPattern value="%-5level %date %-50%type %-40%method
%message%newline" />

    </layout>

  </appender>


************************************************************************
Bunnings Legal Disclaimer:

1) This email is confidential and may contain legally privileged
information. If you are not the intended recipient, you must not
disclose or use the information contained in it. If you have received
this email in error, please notify us immediately by return email and
delete the document.

2) All emails sent to and sent from Bunnings Group Limited.
are scanned for content. Any material deemed to contain inappropriate
subject matter will be reported to the email administrator of all
parties concerned.
************************************************************************


************************************************************************
Bunnings Legal Disclaimer:

1)     This email is confidential and may contain legally privileged
information.  If you are not the intended recipient, you must not
disclose or use the information contained in it.  If you have received
this email in error, please notify us immediately by return email and
delete the document.

2)     All emails sent to and sent from Bunnings Group Limited.
are scanned for content.  Any material deemed to contain inappropriate
subject matter will be reported to the email administrator of all
parties concerned.
************************************************************************

Reply via email to