views:

47

answers:

0

I need the ability to log to create new log files and specify the name of the file at runtime using log4net. I am currently using a RollingFileAppender and it logs everything to one file given the name specified in the app.config.

How can I explicitly tell log4net to start a new log and to name it accordingly?

My Current Config:

<log4net>
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender" >
  <file value="Logs\ErrorLog.log"/>
  <appendToFile value="true"/>
  <maxiumFileSize value="100KB"/>
  <maxuimRollBackups value="2"/>
  <lockingModel type="log4net.Appender.FileAppender+MinimalLock"/>
  <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%message%newline" />
  </layout>
</appender>
<root>
  <level value="INFO" />
  <level value="ERROR" />
  <appender-ref ref="RollingFile" />
</root>

Thanks!

EDIT

I believe my question is a duplicate of this one which has an answer.