logging-log4net-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Krzysztof L. (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LOG4NET-378) Rolling log file is overwritten when application is restarted
Date Wed, 20 Aug 2014 08:54:26 GMT

    [ https://issues.apache.org/jira/browse/LOG4NET-378?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14103641#comment-14103641
] 

Krzysztof L. commented on LOG4NET-378:
--------------------------------------

Hello

Patch provided in commit (http://svn.apache.org/repos/asf/logging/log4net/trunk):
{quote}
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
{quote}

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

bq. <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:

{quote}
    <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>
{quote}

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

{quote}
Log4NetTester_2014-08-29.2.log
Log4NetTester_2014-08-29.1.log
Log4NetTester_2014-08-29.0.log
{quote}

Same effect could be probably achieved by this:

{quote}
    <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>
{quote}

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

> Rolling log file is overwritten when application is restarted
> -------------------------------------------------------------
>
>                 Key: LOG4NET-378
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-378
>             Project: Log4net
>          Issue Type: Bug
>          Components: Appenders
>    Affects Versions: 1.2.11
>            Reporter: Horst Beham
>            Assignee: Dominik Psenner
>            Priority: Critical
>             Fix For: 1.2.12
>
>
> 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>



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message