I’m trying to customise a log4net file path to use a property I have set in the log4net.GlobalContext.Properties dictionary.
log4net.GlobalContext.Properties['LogPathModifier'] = 'SomeValue';
I can see that this value is set correctly when debugging through it. and then in my configuration
<file type='log4net.Util.PatternString' value='Logs\%appdomain_%property{LogPathModifier}.log' />
However, the output of this gives me ‘_(null).log’ at the end of the path. What gives?
I ran into the same behavior and solved it by setting the global variable before calling the XmlConfigurator… Here is what I am successfully using:
log4net.config details:
Global.asax details:
Hope this helps…