Log4net
  1. Log4net
  2. LOG4NET-378

Rolling log file is overwritten when application is restarted

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 1.2.11
    • Fix Version/s: 1.2.12
    • Component/s: Appenders
    • Labels:
      None

      Description

      My server process uses log files which roll on date and file size (4MB).
      When I restart the server and there are already more than 1 log files for the current date, the 2nd segment gets overwritten and the 3rd, 4th, ... may get overwritten later, when #2 is filled up again.
      I'm using version 1.2.11, which I can't select in the "Affects Version" combo box.

      e.g.
      flotto.20130527.0.log = 4MB
      flotto.20130527.1.log = 0MB (just got overwritten when the server was restarted)
      flotto.20130527.2.log = 4MB (still contains original data but will be overwritten too as soon as #1 fills up)
      flotto.20130527.3.log = 4MB (same as above)

      The configuration in MyServer.exe.config looks like this:
      <log4net>
      <appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender">
      <file value="flotto.log" />
      <appendToFile value="true" />
      <encoding>utf-8</encoding>
      <preserveLogFileNameExtension value="true"/>
      <rollingStyle value="Composite" />
      <staticLogFileName value="false" />
      <datePattern value=".yyyyMMdd"/>
      <countDirection value="1"/>
      <maximumFileSize value="4MB" />
      <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date [%-7thread] %-5level %-35logger - %message%newline" />
      </layout>
      </appender>
      <root>
      <level value="INFO" />
      <appender-ref ref="LogFileAppender"/>
      </root>
      <logger name="Flotto.FlottoService">
      <!-<level value="DEBUG"/>->
      </logger>
      <logger name="Flotto.TcpServer">
      <!-<level value="DEBUG"/>->
      </logger>
      <logger name="Flotto.UdpBroadcastReceiver">
      <!-<level value="DEBUG"/>->
      </logger>
      <logger name="Flotto.GpsTrackerGprsServer">
      <level value="DEBUG"/>
      </logger>
      <logger name="Flotto.SmsAtHttpReceiver">
      <level value="DEBUG"/>
      </logger>
      <logger name="Flotto.SmsAtHttpSender">
      <level value="DEBUG"/>
      </logger>
      <logger name="Flotto.BulksmsComHttpReceiver">
      <level value="DEBUG"/>
      </logger>
      <logger name="Flotto.BulksmsComHttpSender">
      <level value="DEBUG"/>
      </logger>
      <logger name="Flotto.TrackerManager">
      <!-<level value="INFO"/>->
      </logger>
      </log4net>

        Issue Links

          Activity

          Hide
          Dominik Psenner added a comment - - edited

          I believe that the logger does what you told him to. If you want to keep files, you could fix your datePattern to contain a more accurate timestamp:

          <datePattern value="yyyyMMddHHmm" />

          This way the file will get overwritten only if the application logs more than 4mb within a minute or does a stop/start cycle in that time.

          Show
          Dominik Psenner added a comment - - edited I believe that the logger does what you told him to. If you want to keep files, you could fix your datePattern to contain a more accurate timestamp: <datePattern value="yyyyMMddHHmm" /> This way the file will get overwritten only if the application logs more than 4mb within a minute or does a stop/start cycle in that time.
          Hide
          Horst Beham added a comment -

          The observed behavior doesn't make much sense to me.
          Why would the logger on restart keep file #0 unchanged, overwrites #1 and leaves #2 and #3 in place for the time being and overwrite it later eventually?
          It looks like the logger doesn't find the correct "end" of the log for appending.

          Loosing log information is certainly a severe problem for me. If I can help in any way resolving this issue, I'm happy to do so.

          Regards,
          Horst

          Show
          Horst Beham added a comment - The observed behavior doesn't make much sense to me. Why would the logger on restart keep file #0 unchanged, overwrites #1 and leaves #2 and #3 in place for the time being and overwrite it later eventually? It looks like the logger doesn't find the correct "end" of the log for appending. Loosing log information is certainly a severe problem for me. If I can help in any way resolving this issue, I'm happy to do so. Regards, Horst
          Hide
          Horst Beham added a comment -

          Hi Dominik, thanks for looking into this issue.
          The log files have that specific naming pattern because they can be viewed on client machines using a date filter and the protocol doesn't allow more than 4MB to be transmitted at a time. Typically 4MB is enough to hold data for a whole day, unless something goes really wrong.

          When using <appendToFile value="true" /> I'd expect the logger to never overwrite any existing log data. Even more confusing is the fact that it keeps file #0, #2 and #3 and starts with overwriting #1.

          Show
          Horst Beham added a comment - Hi Dominik, thanks for looking into this issue. The log files have that specific naming pattern because they can be viewed on client machines using a date filter and the protocol doesn't allow more than 4MB to be transmitted at a time. Typically 4MB is enough to hold data for a whole day, unless something goes really wrong. When using <appendToFile value="true" /> I'd expect the logger to never overwrite any existing log data. Even more confusing is the fact that it keeps file #0, #2 and #3 and starts with overwriting #1.
          Hide
          Dominik Psenner added a comment -

          Alright, now this description would seem that #1 got truncated. This may well be the case if you killed the process.

          If a process has files open it can happen that those files get truncated if the process is killed. That's not a log4net issue and it would occur to me that this is much more likely the cause of the issue.

          Show
          Dominik Psenner added a comment - Alright, now this description would seem that #1 got truncated. This may well be the case if you killed the process. If a process has files open it can happen that those files get truncated if the process is killed. That's not a log4net issue and it would occur to me that this is much more likely the cause of the issue.
          Hide
          Horst Beham added a comment -

          When I shut down the server, all log files are perfectly fine. It's a clean application shutdown, not a kill-process.
          As soon as I start the server process again, file #1 (which is the 2nd segment) gets truncated.

          If there is only 1 file (#0) and its size is less than 4MB, data is appended to it as expected. As soon as there is more than 1 segment, data gets overwritten

          Show
          Horst Beham added a comment - When I shut down the server, all log files are perfectly fine. It's a clean application shutdown, not a kill-process. As soon as I start the server process again, file #1 (which is the 2nd segment) gets truncated. If there is only 1 file (#0) and its size is less than 4MB, data is appended to it as expected. As soon as there is more than 1 segment, data gets overwritten
          Hide
          Dominik Psenner added a comment -

          The RollingFileAppender is broken in many ways - maybe this is just another one. Can you debug this? The interesting stuff should go on in log4net.Appender.RollingFileAppender, especially the method AdjustFileBeforeAppend(). I'm wondering for example if the rolling is done twice (first by date and then by size).

          Show
          Dominik Psenner added a comment - The RollingFileAppender is broken in many ways - maybe this is just another one. Can you debug this? The interesting stuff should go on in log4net.Appender.RollingFileAppender, especially the method AdjustFileBeforeAppend(). I'm wondering for example if the rolling is done twice (first by date and then by size).
          Hide
          Dominik Psenner added a comment - - edited

          Have you looked into the file if log events are really missing? Maybe rolling did everything as expected and just happened to roll an empty file? Composite rolling does not roll by "Date differs and Size is bigger" but "Date differs OR Size is bigger".

          Show
          Dominik Psenner added a comment - - edited Have you looked into the file if log events are really missing? Maybe rolling did everything as expected and just happened to roll an empty file? Composite rolling does not roll by "Date differs and Size is bigger" but "Date differs OR Size is bigger".
          Hide
          Horst Beham added a comment - - edited

          Data is definitively lost.
          File "flotto.20130527.1.log" had 4MB of log data in it (which was then rolled over to flotto.20140527.2.log) and when the process was restarted file 1.log got truncated and is currently being written to.
          I can see original log statements and timestamps in 0.log, 2.log, 3.log. The original information from 1.log is missing and the file only contains log statements since the process restarted.
          When I restart the process again, file 1.log is being truncated again even though it's currently only 100KB in size.

          The intention of my composite rolling appender is to roll the file when the date changes or when the current file is already larger than 4MB.
          I'll download the sources now and try to find the problematic code

          Show
          Horst Beham added a comment - - edited Data is definitively lost. File "flotto.20130527.1.log" had 4MB of log data in it (which was then rolled over to flotto.20140527.2.log) and when the process was restarted file 1.log got truncated and is currently being written to. I can see original log statements and timestamps in 0.log, 2.log, 3.log. The original information from 1.log is missing and the file only contains log statements since the process restarted. When I restart the process again, file 1.log is being truncated again even though it's currently only 100KB in size. The intention of my composite rolling appender is to roll the file when the date changes or when the current file is already larger than 4MB. I'll download the sources now and try to find the problematic code
          Hide
          Horst Beham added a comment -

          After debugging the code I pinned down the problem to two facts:
          1) I'm not initializing MaxSizeRollBackups in my config file and the default value of 0 causes files to be overwritten. Why it leaves file *.0.log in place and overwrite only *.1.log and higher is something I haven't investigated further.
          2) An incompatibility between "PreserveLogFileNameExtension" and RollingMode.Composite. In this case the RollingFileAppender.InitializeFromOneFile() method fails to recognize files which have both a date and a segment number inserted between the file's base name and the extension.

          To fix the problem I modified RollingFileAppender line 904 to look like this:

          // Only look for files in the current roll point
          if (m_rollDate && !m_staticLogFileName)
          {
          string date = m_dateTime.Now.ToString(m_datePattern, System.Globalization.DateTimeFormatInfo.InvariantInfo);
          string prefix = m_preserveLogFileNameExtension ? Path.GetFileNameWithoutExtension(baseFile) + date : baseFile + date;
          string suffix = m_preserveLogFileNameExtension ? Path.GetExtension(baseFile) : "";
          if (! curFileName.StartsWith(prefix) || !curFileName.EndsWith(suffix))

          { LogLog.Debug(declaringType, "Ignoring file ["+curFileName+"] because it is from a different date period"); return; }

          }

          Show
          Horst Beham added a comment - After debugging the code I pinned down the problem to two facts: 1) I'm not initializing MaxSizeRollBackups in my config file and the default value of 0 causes files to be overwritten. Why it leaves file *.0.log in place and overwrite only *.1.log and higher is something I haven't investigated further. 2) An incompatibility between "PreserveLogFileNameExtension" and RollingMode.Composite. In this case the RollingFileAppender.InitializeFromOneFile() method fails to recognize files which have both a date and a segment number inserted between the file's base name and the extension. To fix the problem I modified RollingFileAppender line 904 to look like this: // Only look for files in the current roll point if (m_rollDate && !m_staticLogFileName) { string date = m_dateTime.Now.ToString(m_datePattern, System.Globalization.DateTimeFormatInfo.InvariantInfo); string prefix = m_preserveLogFileNameExtension ? Path.GetFileNameWithoutExtension(baseFile) + date : baseFile + date; string suffix = m_preserveLogFileNameExtension ? Path.GetExtension(baseFile) : ""; if (! curFileName.StartsWith(prefix) || !curFileName.EndsWith(suffix)) { LogLog.Debug(declaringType, "Ignoring file ["+curFileName+"] because it is from a different date period"); return; } }
          Hide
          Horst Beham added a comment -

          A unit test for it (which doesn't quite follow the pattern of the other tests) would be:

          #region CompositeLoggerWithPreserveLogFileExtensionTest
          [Test]
          public void CompositeLoggerWithPreserveLogFileExtensionTest()

          { string baseName = Path.GetFileNameWithoutExtension(c_fileName); string ext = Path.GetExtension(c_fileName); // delete old test files foreach (var file in Directory.GetFiles(Environment.CurrentDirectory, baseName + "*")) File.Delete(file); var raf = CreateCompositeRollingFileAppender(); const string oldMessage = "1234567890"; LoggingEventData led = new LoggingEventData(); led.Message = oldMessage; raf.DoAppend(new LoggingEvent(led)); raf.DoAppend(new LoggingEvent(led)); raf.DoAppend(new LoggingEvent(led)); Assert.IsTrue(File.Exists(baseName + ".20130527.0" + ext)); Assert.AreEqual(oldMessage + Environment.NewLine, File.ReadAllText(baseName + ".20130527.0" + ext)); Assert.IsTrue(File.Exists(baseName + ".20130527.1" + ext)); Assert.IsTrue(File.Exists(baseName + ".20130527.2" + ext)); Assert.IsFalse(File.Exists(baseName + ".20130527.3" + ext)); // simulate application restart raf.Close(); raf = CreateCompositeRollingFileAppender(); const string newMessage = "ABCDEFGHIJ"; led.Message = newMessage; raf.DoAppend(new LoggingEvent(led)); Assert.AreEqual(oldMessage + Environment.NewLine, File.ReadAllText(baseName + ".20130527.0" + ext)); Assert.AreEqual(oldMessage + Environment.NewLine, File.ReadAllText(baseName + ".20130527.1" + ext)); Assert.AreEqual(oldMessage + Environment.NewLine, File.ReadAllText(baseName + ".20130527.2" + ext)); Assert.IsTrue(File.Exists(baseName + ".20130527.3" + ext)); raf.Close(); Assert.AreEqual(newMessage + Environment.NewLine, File.ReadAllText(baseName + ".20130527.3" + ext)); }

          private static RollingFileAppender CreateCompositeRollingFileAppender()

          { RollingFileAppender raf = new RollingFileAppender(); raf.File = c_fileName; raf.AppendToFile = true; raf.Encoding = Encoding.UTF8; raf.PreserveLogFileNameExtension = true; raf.RollingStyle = RollingFileAppender.RollingMode.Composite; raf.StaticLogFileName = false; raf.DatePattern = ".yyyyMMdd"; raf.CountDirection = +1; raf.MaximumFileSize = "10"; raf.MaxSizeRollBackups = -1; var layout = new PatternLayout(); raf.Layout = layout; layout.ConversionPattern = "%message%newline"; raf.ActivateOptions(); raf.DateTimeStrategy = new TestDateTimeStragety(); return raf; }

          class TestDateTimeStragety : RollingFileAppender.IDateTime
          {
          public DateTime Now { get

          { return new DateTime(2013, 5, 27, 13, 06, 00); }

          }
          }
          #endregion

          Show
          Horst Beham added a comment - A unit test for it (which doesn't quite follow the pattern of the other tests) would be: #region CompositeLoggerWithPreserveLogFileExtensionTest [Test] public void CompositeLoggerWithPreserveLogFileExtensionTest() { string baseName = Path.GetFileNameWithoutExtension(c_fileName); string ext = Path.GetExtension(c_fileName); // delete old test files foreach (var file in Directory.GetFiles(Environment.CurrentDirectory, baseName + "*")) File.Delete(file); var raf = CreateCompositeRollingFileAppender(); const string oldMessage = "1234567890"; LoggingEventData led = new LoggingEventData(); led.Message = oldMessage; raf.DoAppend(new LoggingEvent(led)); raf.DoAppend(new LoggingEvent(led)); raf.DoAppend(new LoggingEvent(led)); Assert.IsTrue(File.Exists(baseName + ".20130527.0" + ext)); Assert.AreEqual(oldMessage + Environment.NewLine, File.ReadAllText(baseName + ".20130527.0" + ext)); Assert.IsTrue(File.Exists(baseName + ".20130527.1" + ext)); Assert.IsTrue(File.Exists(baseName + ".20130527.2" + ext)); Assert.IsFalse(File.Exists(baseName + ".20130527.3" + ext)); // simulate application restart raf.Close(); raf = CreateCompositeRollingFileAppender(); const string newMessage = "ABCDEFGHIJ"; led.Message = newMessage; raf.DoAppend(new LoggingEvent(led)); Assert.AreEqual(oldMessage + Environment.NewLine, File.ReadAllText(baseName + ".20130527.0" + ext)); Assert.AreEqual(oldMessage + Environment.NewLine, File.ReadAllText(baseName + ".20130527.1" + ext)); Assert.AreEqual(oldMessage + Environment.NewLine, File.ReadAllText(baseName + ".20130527.2" + ext)); Assert.IsTrue(File.Exists(baseName + ".20130527.3" + ext)); raf.Close(); Assert.AreEqual(newMessage + Environment.NewLine, File.ReadAllText(baseName + ".20130527.3" + ext)); } private static RollingFileAppender CreateCompositeRollingFileAppender() { RollingFileAppender raf = new RollingFileAppender(); raf.File = c_fileName; raf.AppendToFile = true; raf.Encoding = Encoding.UTF8; raf.PreserveLogFileNameExtension = true; raf.RollingStyle = RollingFileAppender.RollingMode.Composite; raf.StaticLogFileName = false; raf.DatePattern = ".yyyyMMdd"; raf.CountDirection = +1; raf.MaximumFileSize = "10"; raf.MaxSizeRollBackups = -1; var layout = new PatternLayout(); raf.Layout = layout; layout.ConversionPattern = "%message%newline"; raf.ActivateOptions(); raf.DateTimeStrategy = new TestDateTimeStragety(); return raf; } class TestDateTimeStragety : RollingFileAppender.IDateTime { public DateTime Now { get { return new DateTime(2013, 5, 27, 13, 06, 00); } } } #endregion
          Hide
          Dominik Psenner added a comment -

          Looks like this is another special case of LOG4NET-369 and LOG4NET-337. Can you confirm that? I commited your proposed fix as revision 1486596.

          Show
          Dominik Psenner added a comment - Looks like this is another special case of LOG4NET-369 and LOG4NET-337 . Can you confirm that? I commited your proposed fix as revision 1486596.
          Hide
          Horst Beham added a comment -

          LOGNET-369 is something different. It uses <staticLogFileName value="true" /> and the default CountDirection. I believe in that scenario the problem was that existing log files are not renamed correctly when rolling over before the new log file (with a fixed name) was created. Although the file name didn't have the desired naming pattern, no data was lost in this case.

          In my scenario CountDirection is +1 and staticLogFileName=false, so there is no file renaming involved. Debugging the code I noticed that log4net was testing whether a file name starts with a string that was generated by CombinePath(), which only inserted the date but not the segment number before the ".log" extension. Since "flotto.20130527.0.log" doesn't start with "flotto.20130527.log", my existing log segments were ignored.
          When preserveLogFileNameExtension is false, the comparison would be "flotto.log.20130527.0".StartsWith("flotto.log.20130527"), which returns true.

          Show
          Horst Beham added a comment - LOGNET-369 is something different. It uses <staticLogFileName value="true" /> and the default CountDirection. I believe in that scenario the problem was that existing log files are not renamed correctly when rolling over before the new log file (with a fixed name) was created. Although the file name didn't have the desired naming pattern, no data was lost in this case. In my scenario CountDirection is +1 and staticLogFileName=false, so there is no file renaming involved. Debugging the code I noticed that log4net was testing whether a file name starts with a string that was generated by CombinePath(), which only inserted the date but not the segment number before the ".log" extension. Since "flotto.20130527.0.log" doesn't start with "flotto.20130527.log", my existing log segments were ignored. When preserveLogFileNameExtension is false, the comparison would be "flotto.log.20130527.0".StartsWith("flotto.log.20130527"), which returns true.
          Hide
          Dominik Psenner added a comment -

          Ok, quite complicated. Luckily we had someone who could wrap his mind around it. I'm resolving the issue. Feel free to close the issue if you think that it is fixed for good.

          Show
          Dominik Psenner added a comment - Ok, quite complicated. Luckily we had someone who could wrap his mind around it. I'm resolving the issue. Feel free to close the issue if you think that it is fixed for good.
          Hide
          Horst Beham added a comment -

          Works now as expected in SVN trunk revision 1486596

          Show
          Horst Beham added a comment - Works now as expected in SVN trunk revision 1486596
          Hide
          md al added a comment -

          I am facing the same problem mentioned above how can i get a new log4net.dll with the above fix ?
          Thanks.

          Show
          md al added a comment - I am facing the same problem mentioned above how can i get a new log4net.dll with the above fix ? Thanks.
          Hide
          Dominik Psenner added a comment -
          Show
          Dominik Psenner added a comment - You'll have to build it. Any svn revision after 1486596 should do (as pointed out in the above comment https://issues.apache.org/jira/browse/LOG4NET-378?focusedCommentId=13667805&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13667805 ).
          Hide
          md al added a comment -

          I am still facing the issue that when i stop and then start the application all the previous created logs are being overwritten rather than continuing from the 5th log file for example.

          my configuration is as follows:

          <log4net>
          <appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender">
          <file value="c:\Logs\" />
          <datePattern value="yyyyMMdd\\\\'Adaptor'\\\\'Adaptor_'yyyyMMdd.lo\g" />
          <preserveLogFileNameExtension value="true" />
          <appendToFile value="true" />
          <rollingStyle value="Composite" />
          <maxSizeRollBackups value="-1" />
          <maximumFileSize value="2MB" />
          <staticLogFileName value="false" />
          <preserveLogFileNameExtension value="true" />
          <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%date

          {yyyy-MM-dd HH:mm:ss.fff}

          [%thread] %level %message %exception%newline" />
          </layout>
          </appender>
          <logger name="LogLogger">
          <level value="DEBUG" />
          <appender-ref ref="LogFileAppender" />
          </logger>
          </log4net>

          Thanks.

          Show
          md al added a comment - I am still facing the issue that when i stop and then start the application all the previous created logs are being overwritten rather than continuing from the 5th log file for example. my configuration is as follows: <log4net> <appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender"> <file value="c:\Logs\" /> <datePattern value="yyyyMMdd\\\\'Adaptor'\\\\'Adaptor_'yyyyMMdd.lo\g" /> <preserveLogFileNameExtension value="true" /> <appendToFile value="true" /> <rollingStyle value="Composite" /> <maxSizeRollBackups value="-1" /> <maximumFileSize value="2MB" /> <staticLogFileName value="false" /> <preserveLogFileNameExtension value="true" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date {yyyy-MM-dd HH:mm:ss.fff} [%thread] %level %message %exception%newline" /> </layout> </appender> <logger name="LogLogger"> <level value="DEBUG" /> <appender-ref ref="LogFileAppender" /> </logger> </log4net> Thanks.
          Hide
          Horst Beham added a comment -

          IMO the file name extension should be part of <file value="..."> and not part of the <datePattern>.
          Also, <preserveLogFileNameExtension> is specified twice.

          My working config looks like this. Files are named "flotto.yyyyMM.x.log"

          <appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender">
          <file value="flotto.log" />
          <appendToFile value="true" />
          <encoding>utf-8</encoding>
          <preserveLogFileNameExtension value="true"/>
          <rollingStyle value="Composite" />
          <staticLogFileName value="false" />
          <datePattern value=".yyyyMMdd"/>
          <countDirection value="1"/>
          <maxSizeRollBackups value="-1" />
          <maximumFileSize value="4MB" />
          <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%date [%-7thread] %-5level %-35logger - %message%newline" />
          </layout>
          </appender>

          Show
          Horst Beham added a comment - IMO the file name extension should be part of <file value="..."> and not part of the <datePattern>. Also, <preserveLogFileNameExtension> is specified twice. My working config looks like this. Files are named "flotto.yyyyMM.x.log" <appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender"> <file value="flotto.log" /> <appendToFile value="true" /> <encoding>utf-8</encoding> <preserveLogFileNameExtension value="true"/> <rollingStyle value="Composite" /> <staticLogFileName value="false" /> <datePattern value=".yyyyMMdd"/> <countDirection value="1"/> <maxSizeRollBackups value="-1" /> <maximumFileSize value="4MB" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date [%-7thread] %-5level %-35logger - %message%newline" /> </layout> </appender>
          Hide
          md al added a comment -

          but if i want to put the log Adaptor.yyyMMdd.x.log in a folder of c:\Logs\yyyyMMdd\Adaptor\ yyyyMMdd being a folder named 20130620 how can i achieve that ?

          Show
          md al added a comment - but if i want to put the log Adaptor.yyyMMdd.x.log in a folder of c:\Logs\yyyyMMdd\Adaptor\ yyyyMMdd being a folder named 20130620 how can i achieve that ?
          Hide
          Dominik Psenner added a comment -

          As far as I know, you can't. Given how the RFA rolling is implemented right now it is impossible to detect old rotated logfiles when they are spread across different directories and searching the entire directory tree to achieve that feature wouldn't be any wiser.

          The plan is to rewrite the rolling file appender: https://issues.apache.org/jira/browse/LOG4NET-367

          Show
          Dominik Psenner added a comment - As far as I know, you can't. Given how the RFA rolling is implemented right now it is impossible to detect old rotated logfiles when they are spread across different directories and searching the entire directory tree to achieve that feature wouldn't be any wiser. The plan is to rewrite the rolling file appender: https://issues.apache.org/jira/browse/LOG4NET-367
          Hide
          Krzysztof L. added a comment -

          Hello

          Patch provided in commit (http://svn.apache.org/repos/asf/logging/log4net/trunk):

          Revision: 1486596
          Author: dpsenner
          Date: 27.05.2013 14:45:46
          Message:
          LOG4NET-378 fixed a problem where rolled log files get overwritten when the application is restarted

          The cause is that InitializeFromOneFile() does not succesfully detect the filenames.


          Modified : /logging/log4net/trunk/src/Appender/RollingFileAppender.cs

          works OK for configuration provided in "Description" of this ticket. But it does NOT WORK in scenario when datePattern has additional uppercase characters, eg:

          <datePattern value="'Module_XYZ_'yyyy-MM-dd'.log'"/>

          I know that additional strings could be inserted to <file value=".../> but it would be nice if such datePattern configuration is also supported, especially that the required code patch is not too extensive and will be will be as follows (based on code from Revision 1486596 - see code from InitializeFromOneFile method):

          Line:
          string date = m_dateTime.Now.ToString(m_datePattern, System.Globalization.DateTimeFormatInfo.InvariantInfo);

          should be changed to:

          string date = m_dateTime.Now.ToString(m_datePattern, System.Globalization.DateTimeFormatInfo.InvariantInfo).ToLower();

          So patch is simple to apply... Is it possible to do it? Should I create new ticket or this ticket should be reopenned?


          Appender full configuration which leads to problem:

          <appender name="mainAppender" type="log4net.Appender.RollingFileAppender">
          <file value="logs\" />

          <appendToFile value="true" />
          <encoding>utf-8</encoding>

          <preserveLogFileNameExtension value="true"/>

          <rollingStyle value="Composite" />
          <staticLogFileName value="false" />

          <datePattern value="'Module_XYZ_'yyyy-MM-dd'.log'"/>

          <maxSizeRollBackups value="10" />

          <countDirection value="1"/>
          <maximumFileSize value="30KB" />
          <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%date %-5level %-35logger - %message%newline" />
          </layout>
          </appender>

          This configuration "creates" log files with the following names:

          Log4NetTester_2014-08-29.2.log
          Log4NetTester_2014-08-29.1.log
          Log4NetTester_2014-08-29.0.log

          Same effect could be probably achieved by this:

          <appender name="mainAppender" type="log4net.Appender.RollingFileAppender">
          <file value="logs\Module_XYZ_" />

          <appendToFile value="true" />
          <encoding>utf-8</encoding>

          <preserveLogFileNameExtension value="true"/>

          <rollingStyle value="Composite" />
          <staticLogFileName value="false" />
          <datePattern value="''yyyy-MM-dd'.log'"/>

          <maxSizeRollBackups value="10" />

          <countDirection value="1"/>
          <maximumFileSize value="30KB" />
          <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%date %-5level %-35logger - %message%newline" />
          </layout>
          </appender>

          but problem will occur when someone will use uppercase characters in file extension (<datePattern value="''yyyy-MM-dd'.LOG'"/>)...

          Show
          Krzysztof L. added a comment - Hello Patch provided in commit ( http://svn.apache.org/repos/asf/logging/log4net/trunk): Revision: 1486596 Author: dpsenner Date: 27.05.2013 14:45:46 Message: LOG4NET-378 fixed a problem where rolled log files get overwritten when the application is restarted The cause is that InitializeFromOneFile() does not succesfully detect the filenames. Modified : /logging/log4net/trunk/src/Appender/RollingFileAppender.cs works OK for configuration provided in "Description" of this ticket. But it does NOT WORK in scenario when datePattern has additional uppercase characters, eg: <datePattern value="'Module_XYZ_'yyyy-MM-dd'.log'"/> I know that additional strings could be inserted to <file value=".../> but it would be nice if such datePattern configuration is also supported, especially that the required code patch is not too extensive and will be will be as follows (based on code from Revision 1486596 - see code from InitializeFromOneFile method): Line: string date = m_dateTime.Now.ToString(m_datePattern, System.Globalization.DateTimeFormatInfo.InvariantInfo); should be changed to: string date = m_dateTime.Now.ToString(m_datePattern, System.Globalization.DateTimeFormatInfo.InvariantInfo).ToLower(); So patch is simple to apply... Is it possible to do it? Should I create new ticket or this ticket should be reopenned? Appender full configuration which leads to problem: <appender name="mainAppender" type="log4net.Appender.RollingFileAppender"> <file value="logs\" /> <appendToFile value="true" /> <encoding>utf-8</encoding> <preserveLogFileNameExtension value="true"/> <rollingStyle value="Composite" /> <staticLogFileName value="false" /> <datePattern value="'Module_XYZ_'yyyy-MM-dd'.log'"/> <maxSizeRollBackups value="10" /> <countDirection value="1"/> <maximumFileSize value="30KB" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date %-5level %-35logger - %message%newline" /> </layout> </appender> This configuration "creates" log files with the following names: Log4NetTester_2014-08-29.2.log Log4NetTester_2014-08-29.1.log Log4NetTester_2014-08-29.0.log Same effect could be probably achieved by this: <appender name="mainAppender" type="log4net.Appender.RollingFileAppender"> <file value="logs\Module_XYZ_" /> <appendToFile value="true" /> <encoding>utf-8</encoding> <preserveLogFileNameExtension value="true"/> <rollingStyle value="Composite" /> <staticLogFileName value="false" /> <datePattern value="''yyyy-MM-dd'.log'"/> <maxSizeRollBackups value="10" /> <countDirection value="1"/> <maximumFileSize value="30KB" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date %-5level %-35logger - %message%newline" /> </layout> </appender> but problem will occur when someone will use uppercase characters in file extension (<datePattern value="''yyyy-MM-dd'.LOG'"/>)...
          Hide
          Krzysztof L. added a comment -

          I have found another issue when using second appender configuration from my previous note (https://issues.apache.org/jira/browse/LOG4NET-378?focusedCommentId=14103641&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14103641)...

          Problem from this ticket still occurs when using configuration like that:

          <appender name="mainAppender" type="log4net.Appender.RollingFileAppender">
            <file value="logs\Module_XYZ_" />
          
            <staticLogFileName value="false" />
          
            <appendToFile value="true" />
          
            <encoding>utf-8</encoding>
          
            <preserveLogFileNameExtension value="true"/>
          
            <rollingStyle value="Composite" />
          
            <datePattern value="''yyyy-MM-dd'.log'"/>
          
            <maxSizeRollBackups value="10" />
          
            <countDirection value="1"/>
            
            <maximumFileSize value="30KB" />
            
            <layout type="log4net.Layout.PatternLayout">
              <conversionPattern value="%date %-5level %-35logger - %message%newline" />
            </layout>
          </appender>
          

          Problem does NOT occur if we change preserveLogFileNameExtension to false.

          Problem has source in GetWildcardPatternForFile method from RollingFileAppender.cs - currently it has following content:

          private string GetWildcardPatternForFile(string baseFileName)
          {
              if (m_preserveLogFileNameExtension)
              {
                  return Path.GetFileNameWithoutExtension(baseFileName) + ".*" + Path.GetExtension(baseFileName);
              }
              else
              {
                  return baseFileName + '*';
              }
          }
          

          When we use file options which has NOT file extension (extension is defined in datePattern) AND when we set preserveLogFileNameExtension to true:

              <file value="logs\Module_XYZ_" />
              <preserveLogFileNameExtension value="true"/>
              <datePattern value="''yyyy-MM-dd'.log'"/>
              <rollingStyle value="Composite" />
          

          then code from GetWildcardPatternForFile method will return e.g.:

          "Module_XYZ_.*"
          

          So this is problem, because for this specific appender configuration it should be something like this:

          "Module_XYZ_*"

          or maybe this:

          "Module_XYZ_*."

          In my test app. GetWildcardPatternForFile() is called for first time on application start when logging system is initalizing (ActivateOptions() -> ExistingInit() -> DetermineCurSizeRollBackups() -> GetWildcardPatternForFile()) - so it could be the case because GetWildcardPatternForFile() is called with m_baseFileName which is set to e.g. "C:\log4netTestMultithreaded\bin\Debug\logs\Module_XYZ_" (because base.File has this value in ActivateOptions()) and on latter stage - when file is opened in log4net.Appender.FileAppender.OpenFile()) base.File (m_fileName) - value is set to e.g. "C:\log4netTestMultithreaded\bin\Debug\logs\Module_XYZ_2014-08-20.0.LOG". Maybe when GetWildcardPatternForFile() code was written it was used on later stage or maybe case when in <file value=".." /> option no file extension is defined?


          Another problem with above configuration is that option maxSizeRollBackups Another is not working... Appender creates files with index higher than maxSizeRollBackups...

          I have found that problem is probably in RollOverRenameFiles method which currently contains code like this:

          if (m_countDirection < 0) 
          {
              // (...)
          }
          else
          {
              // (...)
              string archiveFileBaseName = baseFileName;
              if (!m_staticLogFileName)
              {
                  int lastDotIndex = (m_preserveLogFileNameExtension ? Path.GetFileNameWithoutExtension(archiveFileBaseName) : archiveFileBaseName).LastIndexOf(".");
                  if (lastDotIndex >= 0) 
                  {
                      archiveFileBaseName = archiveFileBaseName.Substring(0, lastDotIndex);
                  }
              }
          
              // Delete the archive file
              DeleteFile(CombinePath(archiveFileBaseName, "." + oldestFileIndex));   
              // (...)
          }
          

          For my specific appender configuration archiveFileBaseName is e.g. "C:\log4netTestMultithreaded\bin\Debug\logs\Module_XYZ_2014-08-20.5.LOG" (due to preserveLogFileNameExtension = true setting file name ends with "5.log" and not "log.5")...

          So code in RollOverRenameFiles method should be corrected to take account of such a case...


          Should I create new tickets for this cases or maybe it should be resolved in the context of this LOG4NET-378 ticket?

          Show
          Krzysztof L. added a comment - I have found another issue when using second appender configuration from my previous note ( https://issues.apache.org/jira/browse/LOG4NET-378?focusedCommentId=14103641&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14103641 )... Problem from this ticket still occurs when using configuration like that: <appender name= "mainAppender" type= "log4net.Appender.RollingFileAppender" > <file value= "logs\Module_XYZ_" /> <staticLogFileName value= "false" /> <appendToFile value= "true" /> <encoding> utf-8 </encoding> <preserveLogFileNameExtension value= "true" /> <rollingStyle value= "Composite" /> <datePattern value= "''yyyy-MM-dd'.log'" /> <maxSizeRollBackups value= "10" /> <countDirection value= "1" /> <maximumFileSize value= "30KB" /> <layout type= "log4net.Layout.PatternLayout" > <conversionPattern value= "%date %-5level %-35logger - %message%newline" /> </layout> </appender> Problem does NOT occur if we change preserveLogFileNameExtension to false. Problem has source in GetWildcardPatternForFile method from RollingFileAppender.cs - currently it has following content: private string GetWildcardPatternForFile(string baseFileName) { if (m_preserveLogFileNameExtension) { return Path.GetFileNameWithoutExtension(baseFileName) + ".*" + Path.GetExtension(baseFileName); } else { return baseFileName + '*'; } } When we use file options which has NOT file extension (extension is defined in datePattern) AND when we set preserveLogFileNameExtension to true: <file value= "logs\Module_XYZ_" /> <preserveLogFileNameExtension value= "true" /> <datePattern value= "''yyyy-MM-dd'.log'" /> <rollingStyle value= "Composite" /> then code from GetWildcardPatternForFile method will return e.g.: "Module_XYZ_.*" So this is problem, because for this specific appender configuration it should be something like this: "Module_XYZ_*" or maybe this: "Module_XYZ_*." In my test app. GetWildcardPatternForFile() is called for first time on application start when logging system is initalizing (ActivateOptions() -> ExistingInit() -> DetermineCurSizeRollBackups() -> GetWildcardPatternForFile()) - so it could be the case because GetWildcardPatternForFile() is called with m_baseFileName which is set to e.g. "C:\log4netTestMultithreaded\bin\Debug\logs\Module_XYZ_" (because base.File has this value in ActivateOptions()) and on latter stage - when file is opened in log4net.Appender.FileAppender.OpenFile()) base.File (m_fileName) - value is set to e.g. "C:\log4netTestMultithreaded\bin\Debug\logs\Module_XYZ_2014-08-20.0.LOG". Maybe when GetWildcardPatternForFile() code was written it was used on later stage or maybe case when in <file value=".." /> option no file extension is defined? Another problem with above configuration is that option maxSizeRollBackups Another is not working... Appender creates files with index higher than maxSizeRollBackups... I have found that problem is probably in RollOverRenameFiles method which currently contains code like this: if (m_countDirection < 0) { // (...) } else { // (...) string archiveFileBaseName = baseFileName; if (!m_staticLogFileName) { int lastDotIndex = (m_preserveLogFileNameExtension ? Path.GetFileNameWithoutExtension(archiveFileBaseName) : archiveFileBaseName).LastIndexOf( "." ); if (lastDotIndex >= 0) { archiveFileBaseName = archiveFileBaseName.Substring(0, lastDotIndex); } } // Delete the archive file DeleteFile(CombinePath(archiveFileBaseName, "." + oldestFileIndex)); // (...) } For my specific appender configuration archiveFileBaseName is e.g. "C:\log4netTestMultithreaded\bin\Debug\logs\Module_XYZ_2014-08-20.5.LOG" (due to preserveLogFileNameExtension = true setting file name ends with "5.log" and not "log.5")... So code in RollOverRenameFiles method should be corrected to take account of such a case... Should I create new tickets for this cases or maybe it should be resolved in the context of this LOG4NET-378 ticket?
          Hide
          Kalen.Brown added a comment -

          https://issues.apache.org/jira/browse/LOG4NET-378?focusedCommentId=14103761&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14103761
          with reference to the above comment, I think I am having your issue. I show the same results from my bug except the new versions of log4net do not fix it. I am using preserve log file name extension = true, I am using composite rolling style with size and date, and I have two output files (one for data and the other for debug/info/warn/error....). If I change the size roll over to something very small (to generate the error faster) and I set the date roll over to on the day, and let it generate a .0 .1 .2 file, then restart the application, then the .1 file will ALWAYS be overwritten. It ALWAYS erases the .1 file and begins appending again. I agree with the bug logic in this thread. On longer runs I think it even messes up the dot numbering but that isn't the focus of this bug report. I have tried many different versions of log4net as pulled from the github and the NuGet package manager and none of them fix the issue. The only workaround for us is to use the Date rolling style and set it to roll over on the hour to keep the file sizes in check. However, this is not a sustainable workaround.

          Mainly I want to know what the bug number is for this situation and what its status is because I don't feel that my issue falls under the bug # 378 due to the configuration but I can't find another bug with my specific issue. I was using V1.2.12 but now I run V1.2.13 and have tried the various .net versions that you have recently released. To add assurance, I am reporting the version with "log.Debug("Log4Net Logger version: " + log4net.AssemblyInfo.Version);" which reports "2015-03-09 12:29:51,495 DEBUG S351_BMS_GUI.MainWindow Log4Net Logger version: 1.2.13"

          <!-- Logger Settings -->
          <log4net>
          <appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender">
          <!-- Typical........................"log4net.Appender.RollingFileAppender" -->
          <file value="Logs\EventLog.txt" />
          <!-Typical "Logs\log.txt"->
          <appendToFile value="true" />
          <!-- Typical........"true" Will not overwrite a pre existing file, will only append to the bottom-->
          <immediateFlush value="true" />
          <!-- Typical.........."true" -->
          <rollingStyle value="Composite" />
          <!-- Typical........"Composite" A new file is created when either a value in the date pattern below changes, or when the maximumFileSize is reached (also defined below)-->
          <datePattern value="_yyyy-MM-dd" />
          <!-- Typical......."_yyyy-MM-dd" When any value in this date pattern (the year, month, day, or hour) changes, a new file is created with that date pattern inserted before the file extension.-->
          <countDirection value="0" />
          <!-Typical..........."0"->
          <!-- Change order of file backup to improve performance. -->
          <maxSizeRollBackups value="-1" />
          <!-Typical..............."-1" -1 Will not delete old files. A non negative number would delete old files when the file of that value is exceeded.->
          <!-- Do not delete any backup files if set incorrectly. -->
          <maximumFileSize value="20MB" />
          <!-- Typical..........."20MB" Will create a new file if the current file exceeds this size-->
          <!-- Max file size. -->
          <preserveLogFileNameExtension value="true" />
          <!-- Typical........................"true" true keeps from overwriting the file extension-->
          <staticLogFileName value="false" />
          <!-Typical.............."false" false to allow the file name to change based on the date pattern.->
          <!-- Flags that the current log file is what I specified as filename. -->
          <layout type="log4net.Layout.PatternLayout">
          <!--Typical"log4net.Layout.PatternLayout" -->
          <conversionPattern value="%d %-5p %c %m%n" />
          <!-- Typical............."%d %5p %c %m%n" This is the message that is added to the log where %m is the message and %n is a new line.->
          </layout>
          </appender>
          <appender name="DataLoggerAppender" type="log4net.Appender.RollingFileAppender">
          <!-- Typical "" -->
          <file value="Logs\Data.csv" />
          <!-Typical "Logs\Data.csv"->
          <appendToFile value="true" />
          <!-- Typical........"true" -->
          <immediateFlush value="true" />
          <!-- Typical.........."true" -->
          <rollingStyle value="Composite" />
          <!-- Typical........"Composite" -->
          <datePattern value="_yyyy-MM-dd" />
          <!-- Typical......."_yyyy-MM-dd" -->
          <countDirection value="0" />
          <!-Typical..........."0"->
          <!-- Change order of file backup to improve performance. Typical "0"-->
          <maxSizeRollBackups value="-1" />
          <!-Typical..............."-1" for Do not delete any backup files.->
          <!-maxSizeRollBackups may delete old files if set incorrectly.->
          <maximumFileSize value="20MB" />
          <!-Typical............"20MB"->
          <!-- Max file size. -->
          <preserveLogFileNameExtension value="true" />
          <!-- Typical........................"true" true keeps from overwriting the file extension-->
          <staticLogFileName value="false" />
          <!--Typical.............."false" false to allow the file name to change based on the date pattern. -->
          <layout type="log4net.Layout.DynamicPatternLayout">
          <!--Typical"log4net.Layout.DynamicPatternLayout" -->
          <param name="ConversionPattern" value="%m%n" />
          <!-- Typical.........................."%m%n" -->
          <param name="Header" value ="Header Information%newline" />
          </layout>
          </appender>
          <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
          <!-- Typical........................"log4net.Appender.ConsoleAppender" -->
          <layout type="log4net.Layout.PatternLayout">
          <!--Typical"log4net.Layout.PatternLayout" -->
          <param name="ConversionPattern" value="%d %-5p %c %m%n" />
          <!-- Typical.........................."%d %-5p %c %m%n" -->
          </layout>
          </appender>
          <logger additivity="false" name="DataLogger">
          <!-- Typical.................."DataLogger" -->
          <level value="All" />
          <!-- Typical "All" -->
          <appender-ref ref="DataLoggerAppender" />
          <!-- Typical......"DataLoggerAppender" -->
          </logger>
          <root>
          <level value="INFO" />
          <!-- Typical "INFO"-->
          <!-- log level: ERROR, WARN, INFO, DEBUG options available. -->
          <appender-ref ref="LogFileAppender" />
          <!-- Typical......"LogFileAppender" -->
          <appender-ref ref="ConsoleAppender" />
          <!-- Typical......"ConsoleAppender" -->
          </root>
          </log4net>

          Show
          Kalen.Brown added a comment - https://issues.apache.org/jira/browse/LOG4NET-378?focusedCommentId=14103761&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14103761 with reference to the above comment, I think I am having your issue. I show the same results from my bug except the new versions of log4net do not fix it. I am using preserve log file name extension = true, I am using composite rolling style with size and date, and I have two output files (one for data and the other for debug/info/warn/error....). If I change the size roll over to something very small (to generate the error faster) and I set the date roll over to on the day, and let it generate a .0 .1 .2 file, then restart the application, then the .1 file will ALWAYS be overwritten. It ALWAYS erases the .1 file and begins appending again. I agree with the bug logic in this thread. On longer runs I think it even messes up the dot numbering but that isn't the focus of this bug report. I have tried many different versions of log4net as pulled from the github and the NuGet package manager and none of them fix the issue. The only workaround for us is to use the Date rolling style and set it to roll over on the hour to keep the file sizes in check. However, this is not a sustainable workaround. Mainly I want to know what the bug number is for this situation and what its status is because I don't feel that my issue falls under the bug # 378 due to the configuration but I can't find another bug with my specific issue. I was using V1.2.12 but now I run V1.2.13 and have tried the various .net versions that you have recently released. To add assurance, I am reporting the version with "log.Debug("Log4Net Logger version: " + log4net.AssemblyInfo.Version);" which reports "2015-03-09 12:29:51,495 DEBUG S351_BMS_GUI.MainWindow Log4Net Logger version: 1.2.13" <!-- Logger Settings --> <log4net> <appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender"> <!-- Typical........................"log4net.Appender.RollingFileAppender" --> <file value="Logs\EventLog.txt" /> <!- Typical "Logs\log.txt" -> <appendToFile value="true" /> <!-- Typical........"true" Will not overwrite a pre existing file, will only append to the bottom--> <immediateFlush value="true" /> <!-- Typical.........."true" --> <rollingStyle value="Composite" /> <!-- Typical........"Composite" A new file is created when either a value in the date pattern below changes, or when the maximumFileSize is reached (also defined below)--> <datePattern value="_yyyy-MM-dd" /> <!-- Typical......."_yyyy-MM-dd" When any value in this date pattern (the year, month, day, or hour) changes, a new file is created with that date pattern inserted before the file extension.--> <countDirection value="0" /> <!- Typical..........."0" -> <!-- Change order of file backup to improve performance. --> <maxSizeRollBackups value="-1" /> <!- Typical..............."-1" -1 Will not delete old files. A non negative number would delete old files when the file of that value is exceeded. -> <!-- Do not delete any backup files if set incorrectly. --> <maximumFileSize value="20MB" /> <!-- Typical..........."20MB" Will create a new file if the current file exceeds this size--> <!-- Max file size. --> <preserveLogFileNameExtension value="true" /> <!-- Typical........................"true" true keeps from overwriting the file extension--> <staticLogFileName value="false" /> <!- Typical.............."false" false to allow the file name to change based on the date pattern. -> <!-- Flags that the current log file is what I specified as filename. --> <layout type="log4net.Layout.PatternLayout"> <!--Typical"log4net.Layout.PatternLayout" --> <conversionPattern value="%d %-5p %c %m%n" /> <!-- Typical............."%d % 5p %c %m%n" This is the message that is added to the log where %m is the message and %n is a new line. -> </layout> </appender> <appender name="DataLoggerAppender" type="log4net.Appender.RollingFileAppender"> <!-- Typical "" --> <file value="Logs\Data.csv" /> <!- Typical "Logs\Data.csv" -> <appendToFile value="true" /> <!-- Typical........"true" --> <immediateFlush value="true" /> <!-- Typical.........."true" --> <rollingStyle value="Composite" /> <!-- Typical........"Composite" --> <datePattern value="_yyyy-MM-dd" /> <!-- Typical......."_yyyy-MM-dd" --> <countDirection value="0" /> <!- Typical..........."0" -> <!-- Change order of file backup to improve performance. Typical "0"--> <maxSizeRollBackups value="-1" /> <!- Typical..............."-1" for Do not delete any backup files. -> <!- maxSizeRollBackups may delete old files if set incorrectly. -> <maximumFileSize value="20MB" /> <!- Typical............"20MB" -> <!-- Max file size. --> <preserveLogFileNameExtension value="true" /> <!-- Typical........................"true" true keeps from overwriting the file extension--> <staticLogFileName value="false" /> <!--Typical.............."false" false to allow the file name to change based on the date pattern. --> <layout type="log4net.Layout.DynamicPatternLayout"> <!--Typical"log4net.Layout.DynamicPatternLayout" --> <param name="ConversionPattern" value="%m%n" /> <!-- Typical.........................."%m%n" --> <param name="Header" value ="Header Information%newline" /> </layout> </appender> <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender"> <!-- Typical........................"log4net.Appender.ConsoleAppender" --> <layout type="log4net.Layout.PatternLayout"> <!--Typical"log4net.Layout.PatternLayout" --> <param name="ConversionPattern" value="%d %-5p %c %m%n" /> <!-- Typical.........................."%d %-5p %c %m%n" --> </layout> </appender> <logger additivity="false" name="DataLogger"> <!-- Typical.................."DataLogger" --> <level value="All" /> <!-- Typical "All" --> <appender-ref ref="DataLoggerAppender" /> <!-- Typical......"DataLoggerAppender" --> </logger> <root> <level value="INFO" /> <!-- Typical "INFO"--> <!-- log level: ERROR, WARN, INFO, DEBUG options available. --> <appender-ref ref="LogFileAppender" /> <!-- Typical......"LogFileAppender" --> <appender-ref ref="ConsoleAppender" /> <!-- Typical......"ConsoleAppender" --> </root> </log4net>

            People

            • Assignee:
              Dominik Psenner
              Reporter:
              Horst Beham
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development