Mar 16, 2013 at 4:18 PM
Edited Mar 16, 2013 at 4:32 PM
I know that EventLevel can be changed by modifying the SemanticLogging-svc.xml file for a given EventSource.
What I want to try out is this:
-10 web apps use my CustomAppEventSource : EventSource
-These web apps call CustomAppEventSource.WriteInformationalMessage(string appName, string message)
-At runtime, I want WriteInformationalMessage to change it's EventLevel.Informational to EventLevel.LogAlways -- but based on the passed in appName
(warning: i know passing in the appName is not a good design, but bear with me in this example)
[Event(200, Message = "Generic Informational Message", Level = EventLevel.Informational)]
internal void WriteInformationalMessage(string appName, string message)
-EventLevel newLevel = GetAppDetailsFromConfig(appName).EventLevel
-Use PropertyDescriptor/CategoryAttribute/FieldInfo to set the "Level" attribute to newLevel
I'm considering using one CustomAppEventSource for lots of applications (10+) residing on my environment, because I'd rather have 30+ developers use one CustomAppEventSource that writes to one database table instead of setting up a new EventSource for each
This means that I'm also trying to write a Custom DatabaseEventListener that adds an "ApplicationName" column so that 30+ developers and customers can query this one table based on their application. It also means that I may want to turn on Verbose
logging for just one application in Production (to troubleshoot an issue), and not all applications.
Why am I considering this? Because for many years, all of our developers have been using an internal shared library such as "Company.SharedLibrary.EventLog.WriteEvent()" to write errors to EventVwr. This shared library has done the job of parsing
out the namespace of the webapp, and creating a new Windows event log for brand new apps, on the server, for them. Since eventvwr sucks, is slow (ever try doing 'eventvwr \\server' especially when some developers are on the other side of the world?), hard
to query, and only contains errors, I would like to evolve our approach to logging into all areas such as: Errors, Tracing/Informational, Performance, Auditing. But at the same time, retain our approach to using one common EventLog library (aka EventSource).
On the same note, many new applications are using Elmah or a custom logging approach, and this is starting to get messy and harder to maintain -- hence the push towards every app using a central solution.