Showing posts with label EntLib. Show all posts
Showing posts with label EntLib. Show all posts

Thursday, November 03, 2011

EntLib–Logging–SwitchValues

Here are the list of values that you can use for the SwitchValue for the configuration of the logging block in Enterprise Library.

Value

Description

ActivityTracing

Allows the Stop, Start, Suspend, Transfer, and Resume events through.

All

Allows all events through.

Critical

Allows only Critical events through. A critical event is a fatal error or application crash.

Error

Allows Critical and Error events through. An Error event is a recoverable error.

Information

Allows Critical, Error, Warning, and Information events through. An information event is an informational message.

Off

Does not allow any events through.

Verbose

Allows Critical, Error, Warning, Information, and Verbose events through. A Verbose event is a debugging trace.

Warning

Allows Critical, Error, and Warning events through. A Warning event can indicate both critical and non-critical issues.

MSDN: http://msdn.microsoft.com/en-us/library/ff664426(v=PandP.50).aspx

Monday, April 11, 2011

Routing of Logging Messages–Enterprise Library

A graphic that I drew up to represent the routing of logging messages in EntLib’s Logging Application Block

image

Thursday, October 21, 2010

Enterprise Library–Logging Formatter Token List

Here is the list of tokens available for the text formatter under the logging block:

activity id {activity}
appDomain Name {appDomain}
category {category}
errorMessages {errorMessages}
event Id {eventid}
machine Name {machine}
message {message}
priority {priority}
processId {processId}
processName {processName}
severity {severity}
thread Name {threadName}
timeStamp {timestamp} or {timestamp(local)}
titleToken {title}
win32 ThreadId {win32ThreadId}

Dictionary {dictionary({key} – {value})}

Formatting tokens:
Tab {tab}
NewLine {newline}

Here is a sample template for the text formatter:

"Timestamp: {timestamp(local)}{newline}
{tab}Message: {message}{newline}
{tab}Category: {category}{newline}
{tab}Priority: {priority}{newline}
{tab}EventId: {eventid}{newline}
{tab}Severity: {severity}{newline}
{tab}Title:{title}{newline}
{tab}Machine: {machine}{newline}
{tab}Application Domain: {appDomain}{newline}
{tab}Process Id: {processId}{newline}
{tab}Process Name: {processName}{newline}
{tab}Win32 Thread Id: {win32ThreadId}{newline}
{tab}Thread Name: {threadName}{newline}
{newline}
{tab}Extended Properties: {dictionary({key} - {value})}"

And here is a template formatted for output to XML: (my preferred method for logging to the database)

 template="<log><timestamp>{timestamp(local)}</timestamp>
                    <message>{message}</message>
                    <category>{category}</category>
                    <priority>{priority}</priority>
                    <eventId>{eventid}</eventId>
                    <severity>{severity}</severity>
                    <title>{title}</title>
                    <machine>{machine}</machine>
                    <applicationDomain>{appDomain}</applicationDomain>
                    <processId>{processId}</processId>
                    <processName>{processName}</processName>
                    <win32ThreadId>{win32ThreadId}</win32ThreadId>
                    <threadName>{threadName}</threadName>
                    <extendedProperties>
                     {dictionary(<key>{key}</key><value>{value}</value>)}</extendedProperties></log>"
The < and > are there so that you can insert it in the config file without VS complaining about invalid xml characters.