if you're gonna use a specific Log4Net thing, why won't you simply extend ILogger to have what you need?
On Sun, Mar 22, 2009 at 12:33 AM, Ayende Rahien <[email protected]> wrote: > Use log4net's ThreadContext > > > On Sat, Mar 21, 2009 at 5:57 PM, Callum Hibbert > <[email protected]>wrote: > >> Can someone give me a pointer on how I can get the Event ID populated when >> logging to the Event Log via the Logging Facility and log4net? >> I understand how to do this if I own all the code but I'm having trouble >> seeing an elegant way of passing a value for the Event ID when using the >> Logging Facility. If I owned all the code I would have log4net log a >> "LoggingEvent" as follows: >> >> LoggingEvent loggingEvent = new LoggingEvent(_caller, >> _log.Logger.Repository, _log.Logger.Name, Level.Info, message, >> exception); >> loggingEvent.Properties["EventID"] = eventId; >> _log.Logger.Log(loggingEvent); >> >> I thought about providing the Logging Facility with a custom factory >> (which would provide my own logger) but I'm still bound to the "ILogger" >> interface to which I can only really provide messages in text form, no hook >> for an Event ID. >> >> There is the possibility of setting "EventID" property "globally" on >> log4net before making the call to ILogger (and resetting after the call) >> e.g. >> >> _log4netLogger.Logger.Repository.Properties["EventID"] = eventId; >> >> This is likely to leave me with threading/race conditions when two widgets >> are logging at the same time. >> >> Anyone have any ideas for an elegant solution? >> >> Thanks very much, >> >> Callum >> >> >> > > > > -- Ken Egozi. http://www.kenegozi.com/blog http://www.delver.com http://www.musicglue.com http://www.castleproject.org http://www.gotfriends.co.il --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Castle Project Users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/castle-project-users?hl=en -~----------~----~----~----~------~----~------~--~---
