Request a topic or
contact an Arke consultant
404-812-3123
Log4net and web gardens

Arke Systems Blog

Useful technical and business information straight from Arke.

About the author

Author Name is someone.
E-mail me Send mail

Recent comments

Archive

Authors

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2024

Log4net and web gardens

If you actually want to use more than 1 processor for a website on your fancy multi-processor server (IIS calls this a “web garden” because marketers like to brand new terms for existing technologies), and you’re using a log4net file appender, a default configuration will cause problems for you as your separate web server processes run into locks on the same log file.  To avoid this, you’ll need to configure log4net to put the PID in the filename:

e.g.

<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">

. . .

<file type="log4net.Util.PatternString" value="C:\\IISLogs\\project\\log.pid.%processid.d" />

. . .

<datePattern value="yyyyMMdd'.txt'" />

Unfortunately, this ruins easy filename based date sorting. Don’t know how to do anything about that.

I recommend avoiding the ‘MinimalLock’ configuration that you will see mentioned in google searches. It opens and closes the file for every log message; while I haven’t tested this specifically with log4net, I have run into several apps in the past that ruined their performance by excessive file opening and seeking.


Posted by David Eison on Tuesday, September 1, 2009 4:40 PM
Permalink | Comments (0) | Post RSSRSS comment feed