1

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.

Community
  • 1
  • 1
Nick
  • 19,198
  • 51
  • 185
  • 312
  • 1
    Pragmatically: in a realistic manner; "we want to build a democratic society, but we must act pragmatically" - http://bit.ly/9nJzIz – cjk Sep 29 '10 at 15:51
  • possible duplicate of [Log4Net: Programmatcially specify multiple loggers (with multiple file appenders) ](http://stackoverflow.com/questions/308436/log4net-programmatcially-specify-multiple-loggers-with-multiple-file-appenders) – Mauricio Scheffer Oct 09 '10 at 05:07

0 Answers0