I'm using Enterprise Library 5 Logging block for logging in my windows application, also i defined some extended properties for my log entry, when i define a Database trace listener, and use it to log my message, where are saved my extended properties? in which field?
Asked
Active
Viewed 2,907 times
1 Answers
1
Extended Properties are not logged into a separate column or table with the out of the box Database Trace Listener.
To log Extended Properties, configure a Formatter that logs the Extended Properties:
<formatters>
<add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" template="Timestamp: {timestamp}{newline}
Message: {message}{newline}
Category: {category}{newline}
Priority: {priority}{newline}
EventId: {eventid}{newline}
Severity: {severity}{newline}
Title:{title}{newline}
Machine: {localMachine}{newline}
App Domain: {localAppDomain}{newline}
ProcessId: {localProcessId}{newline}
Process Name: {localProcessName}{newline}
Thread Name: {threadName}{newline}
Win32 ThreadId:{win32ThreadId}{newline}
Extended Properties: {dictionary({key} - {value}{newline})}" name="Text Formatter"/>
</formatters>
Then the Extended Property data will be logged into the FormattedMessage column.
The downside of this is that the Extended Properties are buried in the FormattedMessage. If you wanted a more structured representation of Extended Properties you could create a custom Database Trace Listener.
For an example that logs Extended Properties to a separate table see Extended Properties Trace Listener with Custom Exception Handler.

Randy Levy
- 22,566
- 4
- 68
- 94