Christopher Klein
Christopher Klein

Reputation: 2793

Unable to get desired logging name in RollingLogFileAppender

I'm trying to do what I thought should be simple but after A LOT of searching here and on Google I keep running into the same problem.

I'm trying to get a file name that comes out as:

What I keep on getting is: DistributedWinService.log_2013.07.29.0

<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
  <file value="C:\Logs\server\DistributedWinService.log" />
  <appendToFile value="true" />
  <rollingStyle value="Date" />
  <datePattern value="_yyyy.MM.dd"/>
  <countDirection value="1" />
  <PreserveLogFileNameExtension value="true" />
  <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
  <staticLogFileName value="false" />
  <maximumFileSize value="500KB" />
  <maxSizeRollBackups value="50" />
  <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
  </layout>
</appender>

I'm using the 1.12.11 version of log4net and almost every thread here says to simply add PreserveLogFileNameExtension, which I have done.

What am I missing?

Edit: Per suggestion, tried to change the to and that had no change.

Upvotes: 1

Views: 275

Answers (1)

Peter
Peter

Reputation: 27944

You need to set to Composite instead of Date:

 <rollingStyle value="Composite" />

Composite means it is based on Size and Date.

Upvotes: 1

Related Questions