I want log files to be written to a directory where log files are kept. I'm using a RollingFileAppender with a datePattern. Here is what I have that doesn't work:
<?xml version="1.0" encoding="utf-8"?>
<log4net>
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
<file value="x:\Logs\log" />
<immediateFlush value="true" />
<appendToFile value="true" />
<datePattern value="yyyyMMdd"/>
<maximumFileSize value="10MB" />
<maxSizeRollBackups value="5" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %level %thread %logger - %message%newline" />
</layout>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="RollingFile" />
</root>
</log4net>
I'm hoping this will result in something like:
x:\Logs\log-20211026.log
Instead I get
x:\Logs\log
Examples that I've seen use no path, e.g.:
<file value="log">
<datePattern value="yyyyMMdd"/>
Is there a way to have the data pattern, and an absolute path, and ".log" at the end?
Someone at my work had the answer:
The file name should contain the extention and 2 additional properties need to be set: