enterprise library 3.1 - how to add new configuration property to listener' add tag?
I want to filter Trace Listener based on Severity like Warning,Error etc.
Means if write below listener in the configuration file and add new property "severityFilter" then this listener will catch only Warning and above logs.
So how to create this new property called "severityFilter" bye code ?
<add databaseInstanceName="DB1" writeLogStoredProcName="WriteLog"
addCategoryStoredProcName="Ad开发者_C百科dCategory" formatter="Text Formatter"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
name="Database Trace Listener" severityFilter="Warning" />
Thanks Mitesh Patel
You can't add arbitrary configuration properties to the existing listeners. The listener properties are defined in a configuration data class (in your example FormattedDatabaseTraceListenerData
). If you wanted to add new configuration properties you would have to create a custom listener.
Categories have a SourceLevel
filter which let's you globally filter by severity. But if you want to do it on a TraceListener basis then you should upgrade to a newer version of Enterprise Library -- that feature is supported.
Another option is a custom filter but that acts on a LogEntry
so is also not TraceListener dependent.
精彩评论