Logging Application Block Properties
Retired Content |
---|
This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
The latest Enterprise Library information can be found at the Enterprise Library site. |
The tables in this topic explain the Logging Application Block properties. This topic includes the following sections:
- Trace Listener Properties
- Category Source Properties
- Filter Properties
- Logging Application Block Properties
Trace Listener Properties
These tables explain the properties for the different trace listeners. There are tables for the following trace listeners:
- Custom Trace Listener. This is a class you have created that derives from the CustomTraceListener class.
- Database Trace Listener. This trace listener writes formatted log entries to a database.
- Email Trace Listener. This trace listener sends log entries as e-mail messages.
- Flat File Trace Listener. This trace listener writes log entries to a text file.
- Formatted Event Log Trace Listener. This trace listener formats log entries and writes them to Windows Event Log.
- MSMQ Trace Listener. This trace listener writes log entries to a message queue.
- Rolling Flat File Trace Listener. This trace listener creates a new log file depending on the current log file age and/or size.
- System Diagnostics Trace Listener. This is one of the .NET Framework trace listeners such as the Console Trace Listener.
- WMI Trace Listener. This trace listener raises a WMI management event for each log entry received.
- XML Trace Listener. This trace listener is used to integrate the Logging Application Block with applications that use WCF.
For more information, see the TraceOutputOptions Values table.
Custom Trace Listener
The following table lists the properties that you can set when you add a custom trace listener to the configuration.
Property |
Description |
---|---|
Attributes |
The key/value pairs. To edit these, click the ellipsis button (…) and use the EditableKeyValue Collection Editor. The attributes are a collection of key/value string pairs of configuration information for the custom trace listener. |
Formatter |
The formatter to use with this trace listener. Click the formatter you want to use in the drop-down list. The default is None. This is optional. |
Name |
The name of the trace listener. The default is Custom Trace Listener. This is required. |
TraceOutputOptions |
Trace listeners use this property to determine which options, or elements, should be included in the trace output. Possible values are: CallStack, DateTime, LogicalOperationStack, None, ProcessId, ThreadId, a Timestamp. The default is None. For an explanation of these values, see the TraceOutputOptions Values table. This is optional. |
Type |
The type of the trace listener. The type must derive from the CustomTraceListener class. Click the ellipsis button (…) to view the Type Selector dialog box, and then click the type you want. This is required. |
Database Trace Listener
The following table lists the properties that you can set when you add a Database TraceListener.
Property |
Description |
---|---|
AddCategoryStoredProcedure |
The name of the stored procedure that adds a category. The default is AddCategory. This is required. |
DatabaseInstance |
The name of the database instance to use. The default is None. This is required. |
Filter |
Applies a filter that selects the level of message that it will detect. The valid values are All (the default), Off, Critical, Error, Warning, Information, Verbose, and Activity Tracing. The setting effectively means "the specified level and everything more important." For example, the Warning setting will detect warnings, errors, and critical events. |
Formatter |
The formatter to use with this trace listener. Select one from the drop-down list. The default is None. This is optional. |
Name |
The name of the trace listener. The default is Database Trace Listener. This is required. |
TraceOutputOptions |
A property used by trace listeners to determine which options, or elements, should be included in the trace output. Possible values are CallStack, DateTime, LogicalOperationStack, None, ProcessId, ThreadId, and Timestamp. The default is None. For an explanation of these values, see the TraceOutputOptions Values table. This is optional. |
WriteLogStoredProcedureName |
The name of the stored procedure that writes the log entries. The default is WriteLog. This is required. |
Email Trace Listener
The following table lists the properties that you can set when you add an Email TraceListener.
Property |
Description |
---|---|
Filter |
Applies a filter that selects the level of message that it will detect. The valid values are All (the default), Off, Critical, Error, Warning, Information, Verbose, and Activity Tracing. The setting effectively means "the specified level and everything more important." For example, the Warning setting will detect warnings, errors, and critical events. |
Formatter |
The formatter to use with this trace listener. Select one from the drop-down list. The default is None. This is optional. |
FromAddress |
The address where the log entry originated. The default is from@example.com. This is required. |
Name |
The name of the trace listener. The default is Email Trace Listener. This is required. |
SmtpPort |
The SMTP port that receives e-mail messages. The default is 25. This is optional. |
SmtpServer |
The SMTP server used to send e-mail messages. The default is 127.0.0.1. This is optional. |
SubjectLineEnder |
The subject line suffix. This is optional. |
SubjectLineStarter |
The subject line prefix. This is optional. |
ToAddress |
The address where the log entry is sent. The default is to@example.com. This is required. |
TraceOutputOptions |
Trace listeners use this property to determine which options, or elements, should be included in the trace output. Possible values are: CallStack, DateTime, LogicalOperationStack, None, ProcessId, ThreadId, a Timestamp. The default is None. For an explanation of these values, see the TraceOutputOptions Values table. This is optional. |
Flat File Trace Listener
The following table lists the properties that you can set when you add a FlatFile TraceListener.
Property |
Description |
---|---|
Filename |
The name of the file where entries are written. The default name is trace.log. This is a required value. It can include environment variables such as %WINDIR%, %TEMP%, and %USERPROFILE%. |
Filter |
Applies a filter that selects the level of message that it will detect. The valid values are All (the default), Off, Critical, Error, Warning, Information, Verbose, and Activity Tracing. The setting effectively means "the specified level and everything more important." For example, the Warning setting will detect warnings, errors, and critical events. |
Footer |
Additional information contained in the file footer. The default is "----------------------------------------." This is optional. |
Formatter |
The formatter to use with this trace listener. Select one from the drop-down list. The default is None. This is optional. |
Header |
Additional information contained in the file header. The default is "----------------------------------------." This is optional. |
Name |
The name of the trace listener. The default is FlatFile Trace Listener. This is required. |
TraceOutputOptions |
Trace listeners use this property to determine which options, or elements, should be included in the trace output. Possible values are: CallStack, DateTime, LogicalOperationStack, None, ProcessId, ThreadId, a Timestamp. The default is None. For an explanation of these values, see the TraceOutputOptions Values table. This is optional. |
Note
If the file you specify for the FlatfileTraceListener is read-only, the trace listener does not write the data to the file and no exception occurs. Make sure that the file attributes are set to read/write.
When you use the FlatFileTraceListener class to write log information to a file, the application block locks the file until the application closes. It is possible to open and read the file, but you cannot move or delete the log file until you close the application.
Formatted Event Log Trace Listener
The following table lists the properties that you can set when you add a Formatted EventLog TraceListener.
Property |
Description |
---|---|
Filter |
Applies a filter that selects the level of message that it will detect. The valid values are All (the default), Off, Critical, Error, Warning, Information, Verbose, and Activity Tracing. The setting effectively means "the specified level and everything more important." For example, the Warning setting will detect warnings, errors, and critical events. |
Formatter |
The formatter to use with this trace listener. Select one from the drop-down list. The default is None. This is optional. |
Log |
The name of the event log where entries are written. The default is Application. This is optional. |
MachineName |
The name of the computer on which to write log entries. This is optional. |
Name |
The name of the trace listener. The default is Formatted EventLog TraceListener. This is required. |
Source |
The source name to use when writing to the log. The default is Enterprise Library Logging. This is required. |
TraceOutputOptions |
Trace listeners use this property to determine which options, or elements, should be included in the trace output. Possible values are: CallStack, DateTime, LogicalOperationStack, None, ProcessId, ThreadId, a Timestamp. The default is None. For an explanation of these values, see the TraceOutputOptions Values table. This is optional. |
MSMQ Trace Listener
The following table lists the properties that you can set when you add an Msmq TraceListener.
Property |
Description |
---|---|
Filter |
Applies a filter that selects the level of message that it will detect. The valid values are All (the default), Off, Critical, Error, Warning, Information, Verbose, and Activity Tracing. The setting effectively means "the specified level and everything more important." For example, the Warning setting will detect warnings, errors, and critical events. |
Formatter |
The formatter to use with this trace listener. Select one from the drop-down list. This must be the Binary Formatter when you use this listener with the Message Queuing distributor service. This is optional. |
MessagePriority |
Sets the priority of a log entry. This determines its priority while the log entry is in transit and when it is inserted into its destination queue. Possible values are AboveNormal, High, Highest, Low, Lowest, Normal, VeryHigh, and VeryLow. It applies to the MsmqTraceListener class. The default is Normal. This is optional. |
Name |
The name of the trace listener. The default is Msmq Trace Listener. |
QueuePath |
The path to the queue that the Msmq TraceListener instance uses. This attribute is a message queuing path, and it applies to the MsmqTraceListener class. The default is .\Private$\myQueue. This is required. |
Recoverable |
Specifies whether the log entry is guaranteed to be delivered if there is a computer failure or network problem. The default is False. This is optional. |
TimeToBeReceived |
The total time for a log entry to be received by the destination queue. The default is 49710.06:28:15. This is optional. |
TimeToReachQueue |
The maximum time for the log entry to reach the queue. The default is 49710.06:28:15. This is optional. |
TraceOutputOptions |
Attaches additional information to platform-provided trace listener output. Possible values are CallStack, DateTime, LogicalOperationStack, None, ProcessId, ThreadId, and Timestamp. The default is None. This is optional. |
TransactionType |
The type of a Message Queuing transaction. Possible values are Automatic, None, and Single. It applies to the MsmqTraceListener class. The default is None. This is optional. |
UseAuthentication |
Specifies whether the message was (or must be) authenticated before being sent. The default is False. This is optional. |
UseDeadLetterQueue |
Specifies whether a copy of a message that could not be delivered should be sent to a dead-letter queue. The default is False. This is optional. |
UseEncryption |
Specifies whether to make the message private. The default is False. This is optional. |
Rolling Flat File Trace Listener
The following table lists the properties that you can set when you add a Rolling Flat File Trace Listener. This trace listener allows you to control the size and age of a log file.
Property |
Description |
---|---|
FileName |
This is the name of the rolling flat file. This is a required value. It can include environment variables such as %WINDIR%, %TEMP%, and %USERPROFILE%. |
Filter |
Applies a filter that selects the level of message that it will detect. The valid values are All (the default), Off, Critical, Error, Warning, Information, Verbose, and Activity Tracing. The setting effectively means "the specified level and everything more important." For example, the Warning setting will detect warnings, errors, and critical events. |
Footer |
Additional information contained in the file footer. The default is "----------------------------------------." This is optional. |
Formatter |
The formatter to use with this trace listener. Select one from the drop-down list. The default is None. This is optional. |
Header |
Additional information contained in the file header. The default is "----------------------------------------." This is optional. |
Name |
This is the name of the trace listener. The default is Rolling Flat File Trace Listener. This is required. |
RollFileExistsBehavior |
This property determines what occurs to an existing file when it rolls over. If you select Overwrite, the existing file is overwritten. If you select Increment, the application block creates a new file and names it by incrementing the timestamp. |
RollInterval |
This property determines when the log file rolls over. You can select None (the default), Midnight (in which case the log will roll over at midnight), Minute, Hour, Day, Month, or Year. This is optional. |
RollSizeKB |
This is the maximum size the file can reach, in kilobytes, before it rolls over. This is optional. |
TimeStampPattern |
This is the date/time format that is appended to the new file name (see the Remarks section that follows this table). This is required. |
TraceOutputOptions |
Trace listeners use this property to determine which options, or elements, should be included in the trace output. Possible values are: CallStack, DateTime, LogicalOperationStack, None, ProcessId, ThreadId, and Timestamp. The default is None. For an explanation of these values, see the TraceOutputOptions Values table. This is optional. |
Remarks
- You can control either or both the size of the file and/or its age. For example, if you specify in configuration a RollSizeKB value of 5 KB and a RollInterval value of Day, the file rolls when its size exceeds 5 KB and it also rolls at the end of the day.
- If you select Increment for the RoleFileExistsBehavior, the application block creates a new file when the existing file rolls over. The file name includes the current timestamp. If a file with this name already exists, the application block adds an integer to the end of the timestamp and increments it until it cannot find a file with that name. For example, assume there is a file named mylog2007-01-10.log and the file rolls over while that timestamp is still valid. The application block will then look for a file named mylog2007-01-10.1.log. If no such file exists, it will use that file name for the new file. If that file also exists, it will then attempt to locate the log with the next sequence number mylog2007-01-10.2.log.
- If you select Overwrite for the RoleFileExistsBehavior, the application block creates a new file when the current file rolls over. The name of the file includes the current timestamp. If a file with that name already exists, the application block overwrites the file. If, for some reason, it cannot overwrite the file, it will generate a name using the same process that is used with the Increment value.
- Relative path names resolve to a location that is relative to the AppDomain.CurrentDomain.BaseDirectory directory.
System.Diagnostics TraceListener
The TraceListener class provides the abstract base class for trace listeners that monitor trace and debug output. The following table lists the properties that appear when you add a System.DiagnosticsTraceListener.
Note
If you specify a System.Diagnostics trace listener that writes to a file and that file is read-only, the trace listener does not write the data to the file and no exception occurs. Make sure the file attributes are set to read/write.
Property |
Description |
---|---|
InitData |
If supplied, this property is used when the application block constructs a trace listener. It is a string whose meaning depends on the type of trace listener being constructed. For the .NET Framework trace listeners, the string has the following values: TextWriterTraceListener: filename; XmlWriterListener: filename; DelimitedLIstTraceListener: filename; ConsoleTraceListener: not applicable; DefaultTraceListener: not applicable; EventLogTraceListener: event source name. If the InitData field is not specified, the application block uses the default constructor. If the user specifies the InitData field for a trace listener that does not have a constructor overload that accepts a string, an error occurs. This is optional. |
Name |
The name of the trace listener. The default is System.Diagnostics Trace Listener. This is required. |
TraceOutputOptions |
Trace listeners use this property to determine which options, or elements, should be included in the trace output. Possible values are: CallStack, DateTime, LogicalOperationStack, None, ProcessId, ThreadId, a Timestamp. The default is None. For an explanation of these values, see the TraceOutputOptions Values table. This is optional. |
Type |
The type of the trace listener. Select from the drop-down list. This is required. |
WMI Trace Listener
The WMI Trace Listeneris atrace listener that raises a WMI management event for each log entry it receives. The following table lists the properties that you can set when you add a WMI TraceListener.
Property |
Description |
---|---|
Filter |
Applies a filter that selects the level of message that it will detect. The valid values are All (the default), Off, Critical, Error, Warning, Information, Verbose, and Activity Tracing. The setting effectively means "the specified level and everything more important." For example, the Warning setting will detect warnings, errors, and critical events. |
Name |
The name of the trace listener. The default is WMI Trace Listener. This is required. |
TraceOutputOptions |
Trace listeners use this property to determine which options, or elements, should be included in the trace output. Possible values are: CallStack, DateTime, LogicalOperationStack, None, ProcessId, ThreadId, and Timestamp. The default is None. For an explanation of these values, see the TraceOutputOptions Values table. This is optional. |
XML Trace Listener
The following table lists the properties that you can set when you add an XML TraceListener.
Property |
Description |
---|---|
FileName |
This is the name of the file where the trace listener writes the data it extracts from an XmlLogEntry object. This is a required value. It can include environment variables such as %WINDIR%, %TEMP%, and %USERPROFILE%. |
Filter |
Applies a filter that selects the level of message that it will detect. The valid values are All (the default), Off, Critical, Error, Warning, Information, Verbose, and Activity Tracing. The setting effectively means "the specified level and everything more important." For example, the Warning setting will detect warnings, errors, and critical events. |
Name |
This is the name of the trace listener. The default is XML Trace Listener. This is required. |
TraceOutputOptions |
Trace listeners use this property to determine which options, or elements, should be included in the trace output. Possible values are: CallStack, DateTime, LogicalOperationStack, None, ProcessId, ThreadId, a Timestamp. The default is None. For an explanation of these values, see the TraceOutputOptions Values table. This is optional. |
TraceOutputOptions Values
The following table lists the possible TraceOutputOptions values.
Value |
Description |
---|---|
CallStack |
Write the call stack, which is represented by the return value of the Environment.StackTrace property. |
DateTime |
Write the date and time. |
LogicalOperationsStack |
Write the logical operation stack, which is represented by the return value of the CorrelationManager.LogicalOperationStack property. |
None |
Do not write any elements. |
ProcessId |
Write the process identity, which is represented by the return value of the Process.ID property. |
ThreadId |
Write the ThreadIdentity, which is represented by the return value of the Thread.ManagedThreadIdProperty for the current thread. |
Timestamp |
Write the timestamp, which is represented by the return value of the System.Diagnostics.Stopwatch.GetTimeStamp method. |
Category Source Properties
The following table lists the Category Source properties.
Property |
Description |
---|---|
Name |
The name of the category. The default is Category Source. |
SourceLevels |
Possible values are ActivityTracing, All, Critical, Error, Information, Off, Verbose, and Warning. The default is All. See the following table for more information. |
AutoFlush |
Specifies whether the listener will flush its data to the target after every new entry is written to this source. The default value is True. When set to False, code can flush the entries when required. Note that it is your responsibility to ensure that all entries are flushed to the target, especially if an exception or failure occurs in the application. Otherwise, you will lose any cached logging information not yet written to the target. |
SourceLevels Values
The following table lists the possible SourceLevels values for a category.
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 is a non-critical problem. |
Filter Properties
The following tables explain the properties for the different types of filters. There are tables for the following filters:
- Category Filter. This allows or denies log entries based on their categories.
- LogEnabled Filter. This either enables or disables logging.
- Priority Filter. This allows or denies log entries based on their priorities.
- Custom Filter. This is a filter that you have added to the Logging Application Block.
Category Filter
The following table lists the properties that appear when you add a Category Filter.
Property |
Description |
---|---|
CategoryFilterExpression |
Sets up the rule for denying or allowing the specified categories. Use the Category Filter Editor to configure the expression. |
Name |
The name of the filter. The default is Category Filter. |
LogEnabled Filter
The following table lists the properties that appear when you add a LogEnabled Filter.
Property |
Description |
---|---|
Enabled |
The filter is enabled when this property value is True. The default is False. |
Name |
The name of the filter. The default is LogEnabled Filter. |
Priority Filter
The following table lists the properties that appear when you add a Priority Filter.
Property |
Description |
---|---|
MaximumPriority |
The maximum value a log entry can have to be logged. If you do not set this property, there is no maximum value. |
MinimumPriority |
The minimum value a log entry must have to be logged. If you do not set this property, there is no minimum value. The default is -1. |
Name |
The name of the filter. The default is Priority Filter. |
Custom Filter
The following table lists the properties that appear when you add a Custom Filter.
Property |
Description |
---|---|
Attributes |
The key/value pairs for this filter. Click the ellipsis button (…) and use the EditableKeyValue Collection Editor. |
Name |
The name of the filter. The default is Custom Filter. |
Type |
The type of the trace listener. Select one from the drop-down list. This is required. |
Logging Application Block Properties
The following table lists the properties that appear in the General section when you add the Logging Application Block.
Attribute |
Description |
---|---|
DefaultCategory |
Log entries go to this category if no other category is specified. The default is General. This is required. |
LogWarningsWhenNoCategoriesMatch |
Specifies whether events should be sent to the errors special source trace listener if a log entry contains a category that is not specified in configuration. Possible values are true or false. The default is false. This is optional. |
Name |
The name is Logging Application Block. This is required. |
RevertImpersonation |
Specifies whether to opt-out of impersonation-reverting. To opt-out of the impersonation-reverting default mode, set RevertImpersonation to false. Support includes configuration support, design time support, and manageability support (both WMI and group policy). The default is true. This attribute is optional. |
TracingEnabled |
Specifies whether activity tracing is enabled. Possible values are True or False. The default is False. |
Remarks
Performance testing has demonstrated a 5% performance overhead when reverting impersonation when logging using the rolling flat file trace listener.