I am able to set up log4NET with the ADONetAppender, and all works fine when I want to capture the state of things when I log a message via log.Info(message).
As I will be logging from various locations in my application based on an ActionID which changes throughout the application, how do I extend things so that I may instead issue a call such as log.Info(ActionID, message), with ActionID ending up in the database?
You can add custom fields to log4net using GlobalContext.Properties
before calling log.Info()
by doing something like this:
GlobalContext.Properties["ActionID"] = ActionID;
Then, in your ADONetAppender configuration, you can access this custom field with %property{ActionID}
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With