How to specify common application data folder for log4net?

environment-variables, log4net, logging

Solution

This posting on the log4net mailinglist explains how you can define your own path replacement variables.

Problem

I want log4net to write log files (using RollingFileAppender) to a subfolder of the common application data folder (e.g. C:\Documents and Settings\All Users\Application Data\Company\Product\Logs). However, on Win XP, there is no environment variable that specifies this folder. We have `%ALLUSERSPROFILE%`, we have `%APPDATA%`, but there is nothing like `%ALLUSERSAPPDATA%`. Programatically, I could use `Environment.SpecialFolder.CommonApplicationData`, but I need to put it in the log4net config, something like this: ``` <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender"> <file value="%ALLUSERSAPPDATA%\Company\Product\Logs\error.log" /> </appender> ``` OK, we could define this in our setup, but maybe someone comes up with a better idea?

Original source

Related problems