Advertisement

12.14.2007 at 07:45AM PST, ID: 23023782
[x]
Attachment Details

Log4Net:: How to create a new log file daily with date as part of the log file name?

Asked by Kiran_M in Visual Studio .NET 2005, Microsoft Visual C#.Net

Tags: file, log4net, log, create, date

I am using Log4Net to log messages in a C# Window console application (.Net 2.0). It works fine.  I need to create a new log file daily with Date as part of the log file name. I tried using RollingFileAppender in the config file

<log4net debug="true">
    <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
      <param name="File" value="C:\Kiran_Work\MASSAUTO\temparea\\logfile.log.yyyyMMdd" />
      <param name="AppendToFile" value="true" />
      <param name="rollingStyle" value="Date" />
      <param name="datePattern" value="yyyyMMdd" />
      <layout  type="log4net.Layout.PatternLayout">
      <param name="conversionPattern" value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
      </layout>
    </appender>
    <root>
      <priority value="DEBUG" />
      <appender-ref ref="RollingLogFileAppender" />
    </root>
  </log4net>

It is creating a log file with logfile.log.yyyyMMdd name literally and not substituting the yyyyMMdd with actual date.  What am i doing wrong here?  Do i need set the date in the application code somehow?

Any help is greatly appreciated.
Start Free Trial
[+][-]12.14.2007 at 08:37AM PST, ID: 20472599

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.14.2007 at 08:43AM PST, ID: 20472653

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.14.2007 at 09:30AM PST, ID: 20472982

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.14.2007 at 09:40AM PST, ID: 20473065

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.17.2007 at 06:27AM PST, ID: 20484944

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Visual Studio .NET 2005, Microsoft Visual C#.Net
Tags: file, log4net, log, create, date
Sign Up Now!
Solution Provided By: rallsaldo
Participating Experts: 2
Solution Grade: B
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628