logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ron Grabowski <rongrabow...@yahoo.com>
Subject Re: Log File Naming Problem
Date Sun, 20 Jan 2008 19:42:05 GMT
When a new app domain is created is log4net re-initialized in the new app domain? 

It sounds like the problem is that you have a lot of threads trying to open, close, and roll
the log file. Can you delegate all the locking issues to a database then extract data out
at a later date?

If using a database isn't an option I suggest trying to route all the messages to a single
RollingFileAppender instance configured to use the default ExclusiveLock locking model (MinimalLock
is noticeably slower even for a small amount of logs). A comment from this blog:

 http://www.jasonbock.net/JB/Default.aspx?blog=entry.f48ab22438bc4e35969ca6c559763e9c

mentions using Remoting to channel all the messages from the threads to a single RollingFileAppender
so there is a single thread and class controlling rolling. You coculd use the IpcChannel for
inter-process communications. Is your code similiar to the sample code in the blog post?

If you don't mind me asking, what is the use case for having to create new app domains in
addition to the new threads?

 ----- Original Message ----
From: Steve Wranovsky <wranovsky@gmail.com>
To: log4net-user@logging.apache.org
Sent: Thursday, January 17, 2008 11:10:29 AM
Subject: Log File Naming Problem


Hello,

I have a multi-threaded application using log4net 1.2.10 for logging.
There are a couple of points when the application runs where there are
a large number of logs occurring simultaneously from multiple threads
(that happen to be in different App Domains).  On occasion, I will end
up with two separate log files generated when this point in my
application occurs.  One of the log files will end up with a date
pattern twice in the name and will look something like this:

Server_2008-01-16.log
Server_2008-01-16.log2008-01-16.log

A few of the logs end up in the second log file from one of the
threads.  The remainder of the threads log to the first log file and
continue using it.  Occasionally this second log file will be used
again by another thread if the problem happens again.  Here's the
configuration file I'm using:

<log4net>
                <appender name="RollingLogFileAppender"
type="log4net.Appender.RollingFileAppender">
                                <param name="File"
 value=".\\logs\\Server_" />
                                <param name="AppendToFile" value="true"
 />
                                <param name="MaxSizeRollBackups"
 value="20" />
                                <param name="MaximumFileSize"
 value="10MB" />
                                <param name="RollingStyle"
 value="Composite" />
                                <param name="datePattern"
value="yyyy-MM-dd.lo\g" />
                                <param name="StaticLogFileName"
 value="false" />
                                <layout
 type="log4net.Layout.PatternLayout">
                                                <param
name="ConversionPattern" value="%d [%t] %-5p - %m%n" />
                                </layout>
                                <lockingModel
type="log4net.Appender.FileAppender+MinimalLock" />
                </appender>
                <root>
                                <level value="INFO" />
                                <appender-ref
 ref="RollingLogFileAppender" />
                </root>
</log4net>

It appears that perhaps a lock is failing in one of the threads, and
it by default tries to create another log file to log to.  Is it
possible to block this from happening and have the logs go into the
original log file?  If this is not possible, it would be nice if the
second log file didn't have the double date in it, or if the handling
of this was cleaner.

Thanks,
Steve




Mime
View raw message