Click here to Skip to main content
15,888,802 members
Please Sign up or sign in to vote.
4.67/5 (2 votes)
Hello,

I am using below code in my web.config and I found there are two log files getting created .
For some reason every day the logger switches at times to an alternate log file with the filename (which is supposed to be yyyy-mm-dd.log.text) repeated twice. So there are always two log files.

Please guide me if I am missing something or making any mistake.
XML
<log4net debug="true">
    <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
      <file value="C:\\Logs\\MyProject\\" />
      <appendtofile value="true" />
      <rollingstyle value="Date" />
      <datepattern value="yyyy-MM-dd'.log.txt'" />
            <staticlogfilename value="false" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionpattern value="%date  %level  %type{1}.%method - %message%newline" />
      </layout>
    </appender>
    <root>
      <level value="INFO" />
      <appender-ref ref="RollingLogFileAppender" />
    </root>
  </log4net>

Thanks,
Posted
Updated 30-Jun-14 4:35am
v3

1 solution

You are using the "Rolling File Appender" which as its name suggests rolls to a new file on dates, try using the FileAppender, see here : http://logging.apache.org/log4net/release/config-examples.html[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900