I changed the way the biz.dfch.PS.System.Logging module implements its file writing by using log4net as the file logger. It makes use of the (static) FileAppender as the RollingFileAppender does not support concurrent access when rolling log files.
So the log roll over is still handled within the PowerShell module directly (until I implement a custom lock for rolling the files some day).

The advantage of using log4net is still there: it is considerably faster when writing to log files with several processes at a time (as my previous implementation actually implemented locking similar to the ExclusiveLock in log4net). Plus you can use the other appenders (syslog, eventlog, …) if you feel like it. It just reads an ordinary log4net configuration file on startup where you can finetune your log settings.
Average log performance on a system with 4 processes writing to the log at the same time is approximately 1.2s – 1.5s per call/unbuffered log write.

$start = 10000;
$count = 100000;
$stop = $start + $count
$m = Measure-Command { 
  for($c = $start; $c -lt $stop; $c++) { 
    Out-Log4NetMessage -fn $Host.UI.RawUI.WindowTitle -msg "msg $c"; 
  }; 
}; 
$m.TotalMilliseconds / $count;
1.413476892

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.