gdziadkiewicz commented on issue #163:
URL: 
https://github.com/apache/logging-log4net/issues/163#issuecomment-2680890582

   Hi @WorldRobertProject,
   
   I found some time to dig in properly. The current codebase does not support 
specifying the extension in the `DatePattern`.
   To get the behaviour you are looking for, you could go with:
   ```xml
   <?xml version="1.0" encoding="utf-8" ?>
   <configuration>
     <log4net>
       <appender name="LogFileAppender" 
type="log4net.Appender.RollingFileAppender">
         <param name="File" value=".\Log\.log" />
         <param name="AppendToFile" value="true" />
         <param name="RollingStyle" value="Composite" />
         <param name="DatePattern" value='yyyy-MM-dd' />
         <param name="MaximumFileSize" value="5MB" />
         <param name="MaxSizeRollBackups" value="10" />
         <param name="StaticLogFileName" value="false" />
         <param name="CountDirection" value="1" />
         <param name="PreserveLogFileNameExtension" value="true"/>
         <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
         <layout type="log4net.Layout.PatternLayout">
           <param name="ConversionPattern" value="%d{yyyy/MM/dd HH:mm:ss.fff} 
[%-5p] %m (%M)%n"/>
         </layout>
       </appender>
   
       <logger name="log">
         <level value="debug" />
         <appender-ref ref="LogFileAppender" />
       </logger>
     </log4net>
   </configuration>
   ```
   
   This will work thanks to the ` <param name="PreserveLogFileNameExtension" 
value="true"/>` combined with file extension specified in `<param name="File" 
value=".\Log\.log" />` .
   Resulting log files:
   * `.\Log\2025-02-25.0.log`
   * `.\Log\2025-02-25.1.log`
   ...
   
   You can also use the `File` to add a prefix to the log file names  `<param 
name="File" value=".\Log\prefix.log" />` + ` <param 
name="PreserveLogFileNameExtension" value="true"/>` 
   Resulting log files:
   * `.\Log\prefix2025-02-25.0.log`
   * `.\Log\prefix2025-02-25.1.log`
   
   
   @FreeAndNil I'm wondering if we should add support for specifying the 
extension in the `DatePattern` (could be a breaking change for some users) or 
focus on documenting the current behaviour better.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to