You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by Roman Konovalov <ro...@greenrain.biz> on 2011/10/27 20:48:11 UTC

Log file name gets duplicated

Hi,

 

I've got a situation when my application creates multiple log files, e.g.:

 

1). Greenrain Connect 2011-10-21.log

2). Greenrain Connect 2011-10-21.log Greenrain Connect 2011-10-21.log

3). Greenrain Connect 2011-10-21.log Greenrain Connect 2011-10-21.log
Greenrain Connect 2011-10-21.log

 

Here come more details about our environment:

 

1). log4net.dll file version 1.2.10.0.

 

2). Application config has the following log4net configuration:

  <log4net>

    <appender name="Greenrain Connect"
type="log4net.Appender.RollingFileAppender">

      <param name="File" value="Application Log\"/>

      <param name="RollingStyle" value="Date"/>

      <param name="DatePattern" value="Greenrain Connec\t yyyy-MM-dd.lo\g"/>

      <param name="StaticLogFileName" value="false"/>

      <appendToFile value="true"/>

      <maximumFileSize value="1048576KB"/>

      <!--This property is ignored for Rolling Style Date-->

      <staticLogFileName value="false"/>

      <layout type="log4net.Layout.PatternLayout">

        <conversionPattern value="%date{yyyy-MM-dd HH:mm:ss} [%thread]
%-5level %C{1}.%M (%F:%L) - %m%n"/>

      </layout>

    </appender>

 

    <root>

      <!--Level value would always be ALL as all appenders will inherit this
value. Root's level is the lowest level any appender will have.-->

      <level value="ALL"/>

      <appender-ref ref="Greenrain Connect"/>

    </root>

  </log4net>

 

3). I noticed the following scenario when log files get duplicated:

 

Example 1

We have exe App1.exe that uses Component1.dll. When App1.exe does not call
any function in Component1.dll, when log file name is generated correctly
(e.g. "Greenrain Connect 2011-10-21.log"). As soon as App1.exe calls
functions from Component1.dll, the log file name gets duplicated (e.g.
"Greenrain Connect 2011-10-21.log Greenrain Connect 2011-10-21.log").

 

Example 2

We have two applications App1.exe and App2.exe that both write logs into the
same log file. In this case we get log file with correct name (e.g.
"Greenrain Connect 2011-10-21.log") and second log file with duplicated name
(e.g. "Greenrain Connect 2011-10-21.log Greenrain Connect 2011-10-21.log").

 

Is there anything wrong with my config settings?

 

Thank you in advance for any comments.

 

Best regards,

Roman

 


Re: Log file name gets duplicated

Posted by Stefan Bodewig <bo...@apache.org>.
Hi Roman,

I'm afraid there isn't much help to find from what I'm going to write.
Let me start out by admitting that RollingFileAppender probably is the
biggest pain point of log4net and certainly the component with the most
issues raised against it - and you've likely hit a few of them.

On 2011-10-27, Roman Konovalov wrote:

> 1). log4net.dll file version 1.2.10.0.

Try upgrading to 1.2.11.  Some issues have been fixed, but by far not
all of them.

What you describe sounds a lot like LOG4NET-234 which hasn't been fixed,
yet.  By reading the bug report again and looking at your examples the
problem most likely occurs if log4net cannot write to the log file
without the duplication - as Lee Chun Kit suggest.

> We have two applications App1.exe and App2.exe that both write logs into the
> same log file.

Don't ever do this, this really is asking for trouble.  Even without
rolling the different locking scenarios are all going to cause trouble.

Unless you use a non-default locking model App2 will not be able to
write to the log file (as it is locked by App1) which seems to trigger
the bug.

Stefan

Re: Log file name gets duplicated

Posted by Lee Chun Kit <ch...@gmail.com>.
> Example 1
>
> We have exe App1.exe that uses Component1.dll. When App1.exe does not call any function in Component1.dll, when log file name is generated correctly (e.g. “Greenrain Connect 2011-10-21.log”). As soon as App1.exe calls functions from Component1.dll, the log file name gets duplicated (e.g. “Greenrain Connect 2011-10-21.log Greenrain Connect 2011-10-21.log”).
>
>

See: http://stackoverflow.com/questions/579688/why-is-the-date-appended-twice-on-filenames-when-using-log4net
It may be a file permission issue. If you're running it as a service
under NETWORK_SERVICE, you may want to follow the answer there and
give it more permissions. If file permission proves to be the problem
here, and if security is very important, you might want to create a
limited user account, grant it the minimum working set of permissions
and run your service under this user account.

> Example 2
>
> We have two applications App1.exe and App2.exe that both write logs into the same log file. In this case we get log file with correct name (e.g. “Greenrain Connect 2011-10-21.log”) and second log file with duplicated name (e.g. “Greenrain Connect 2011-10-21.log Greenrain Connect 2011-10-21.log”).
>
>

See "How do I get multiple process (sic) to log to the same file?"
here: http://logging.apache.org/log4net/release/faq.html
There's some advice there to follow.