I want to use log4net to log browser capabilities in a custom property. What is the best context to be used here?
- log4net.GlobalContext
- log4net.ThreadContext
- log4net.ThreadLogicalContext
- log4net.Core.LoggingEvent
I want to use log4net to log browser capabilities in a custom property. What is the best context to be used here?
As you can see in the page you linked to, here are the expected differences of all those contexts:
As you can see the context impacts the scope in which your property lives. Since you want to log browser capabilities you are in a web app, so I suppose multiple threads. If you were to keep properties in a shared context (global) you could risk losing info. I'm not sure about thread contexts since the thread may pick up some other request while waiting on some async data.
In the end the Event context seems the safest and most logical choice since you'll certainly log one event per browser (or per request) and don't need to share this information with the rest of the loggers.