Tuesday, January 24, 2012

NLog. Process specific log file.

For logging into a file which is specific for a process add the ${processid} layout renderer to the log file name.

fileName="${basedir}/logs/log_${shortdate}_${processid}.log"


We use IIS web garden. Some day the log file became a mess, because all instances of our web-site wrote into that single file.


I found a layout renderer for identifier of the current process - ${processid} and added it to the log file name. Now all instances write into separate files.

/logs/logfile_2012-01-24_2708.log
/logs/logfile_2012-01-24_5064.log
/logs/logfile_2012-01-24_6240.log

Done.

No comments: