Is there a way for me to inject properties into a LoggingEvent? I'm trying to accomplish this without the user (of log4net) doing anything special. The only thing I could think of was wrapping loggers, and while I'm not against doing that it would have to be done via configuration as I don't want the user to have to do it programmatically. Is there any way for me to inject a logger wrapper via configuration?
The reason I'm looking to do this is that I would like to set a property on the LoggingEvent to use for filtering. This property would be determined based on the level property. I could simply use the level property for filtering, but I have other events which I generate which are all logged at the Emergency level but have a different value for this property so for them I'm using this property for filtering. I don't have the same issue with these other events because they are logged via an extension method I provided on the ILog interface: public static class Logging { public static void LogEvent(this ILog logger, Category category, IEvent evnt) { if ((category != null) && (evnt != null)) { evnt.SetCategory(category.Name); LoggingEvent le = new LoggingEvent(null, logger.Logger.Respository, logger.Logger.Name, Level.Emergency, evnt, null); le.Properties["category"] = category.Name; logger.Logger.Log(le); } } } So for instance when a user does the following: logger.Error("this is my error message"); or logger.Warn("this is my warning message"); or logger.Info("this is my info message"); I would like to set the property "category" on the LoggingEvent to "criticalDiagnostic". When they do: logger.Debug("this is my debug message"); or logger.Trace("this is my trace message"); I would like to set the property "category" on the LoggingEvent to "noncriticalDiagnostic". Any way for me to do that automagically? I also posted this at: http://stackoverflow.com/questions/40187597/injecting-properties-into-log4nets-loggingevent Thanks, Nick