Log4net does not provide this functionality, but you can easily create it yourself:
- Store several key / value pairs in the configuration file of your choice
- Read the key value pairs at startup and assign it to the global context
The second part will look something like this:
Dictionary<string, string> pairs = ReadGlobalContextConfiguration(); foreach (var pair in pairs) { log4net.GlobalContext.Properties[pair.Key] = pair.Value; }
The first part depends on where you want to save the information. There are many options:
- Configuration section in /Web.config application
- Simple xml file
- Simple text file with
key=value entries per line
source share