<file type="log4net.Util.PatternString">
    <conversionPattern value="C:\Logs\log-%date{
yyyy.MM.dd.HH.mm.ss}-[%processid].log" />
</file>



 

That's the ticket! Thanks. Oddly enough, that has shown me that .net can
tear down an app domain w/out starting a new worker process. I thought a
new app domain (say, changing web.config) always resulted in a new
background process. I hope the locks are held by the process and not by
the domain. J

 

-Walden

 

-- 

Walden H Leverich III
Tech Software
(516) 627-3800 x3051

[EMAIL PROTECTED]
http://www.TechSoftInc.com
<BLOCKED::blocked::http://www.techsoftinc.com/> 

Quiquid latine dictum sit altum viditur.
(Whatever is said in Latin seems profound.)

From: Peter Drier [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, October 09, 2007 10:31 AM
To: Log4NET User
Subject: Re: Including PID in log file name -- Locking Models & ASP.Net

 

Try this..

<appender name="ErrorLogAppender"
type="log4net.Appender.RollingFileAppender">
    <file type="log4net.Util.PatternString">
        <conversionPattern value="C:\Logs\log-%date{
yyyy.MM.dd.HH.mm.ss}-[%processid].log" />
    </file>
    <threshold value="WARN"/>
    <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %location -
%message%newline" /> 
    </layout>
</appender>

-Peter

On 10/9/07, Walden H. Leverich <[EMAIL PROTECTED] > wrote:

Short question: Is there a way in the RollingFileAppender to use the
process ID (PID) in the file name?

 

Long question: 

 

We're using log4net (1.2.10) in several ASP.Net applications. We're also
using the RollingFileAppender rolling daily, and using a static file
name, so the current log-file is "log-file.log" and past log files would
be "log-file.log.2007-08-10.log" for example. 

 

One of the things we've realized is that we need to specify the
FileAppender+MinimalLock locking model in order for this to work. The
reason is, as the ASP.Net worker processes cycle there can be two worker
processes running at the same time, the one that's starting and the one
that's ending. W/out that locking model the new process is unable to get
a lock on the file, because the old process is still running so we miss
logging.

 

What we'd like to is use the PID in the file name of the log file, that
way we know the log file names will be unique and we can get rid of the
FileAppender+MinimalLock locking and increase our logging performance.
So... is there a way in the RollingFileAppender to use the process ID
(PID) in the file name?

 

Ideas?

 

-Walden

 

-- 

Walden H Leverich III
Tech Software
(516) 627-3800 x3051

[EMAIL PROTECTED]
http://www.TechSoftInc.com

Quiquid latine dictum sit altum viditur.
(Whatever is said in Latin seems profound.)

 

Reply via email to