logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dave McEwan" <dmce...@harmonyis.com>
Subject RE: Including PID in log file name -- Locking Models & ASP.Net
Date Tue, 09 Oct 2007 13:40:53 GMT
You could simply grab the PID in your .Net code, and then use the
NDC.Push to push it onto the stack.  It will then be available for
logging.

 

pid = GetPID(); <-- you need to write some code to actually get the PID

using(NDC.Push("pid"))
{
    ... all log calls will have your pid included ...
 
} // at the end of the using block the message is automatically removed 

 

 

Dave

 

  _____  

From: Walden H. Leverich [mailto:WaldenL@TechSoftInc.com] 
Sent: Tuesday, October 09, 2007 9:14 AM
To: Log4NET User
Subject: Including PID in log file name -- Locking Models & ASP.Net

 

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

WaldenL@TechSoftInc.com
http://www.TechSoftInc.com
<BLOCKED::blocked::http://www.techsoftinc.com/> 

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


Mime
View raw message