Enterprise Library 2.0--Logging Application Block (next)

Source: Internet
Author: User
Tags thread win32

Before reading this article, please read: Enterprise Library 2.0--Logging Application Block (upper)

In the previous article we introduced how to configure the logging Application block, this article will mainly introduce the logging Application Block's basic operation as well as the formatter and the trace Listeners custom method, First, let's look at how to write an event log into a text file.

Assuming that we have configured the logging Application Block according to the previous operation, the information in the configuration file is as follows:

<loggingconfiguration name= "Logging Application Block" tracingenabled= "true"
Defaultcategory= "General" logwarningswhennocategoriesmatch= "true" >
<listeners>
<add filename= "Trace.log" header= "----------------------------------------"
Footer= "----------------------------------------" formatter= "SHY520 Formatter"
Listenerdatatype= "Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData,

Microsoft.Practices.EnterpriseLibrary.Logging, version=2.0.0.0, culture=neutral, Publickeytoken=null "
traceoutputoptions= "None" type= " Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener,

Microsoft.Practices.EnterpriseLibrary.Logging, version=2.0.0.0, culture=neutral, Publickeytoken=null "
Name= "SHY520 Listeners"/>
<add source= "Enterprise Library Logging" formatter= "Text Formatter"
log= "Application" machinename= "listenerdatatype=" Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData,

Microsoft.Practices.EnterpriseLibrary.Logging, version=2.0.0.0, culture=neutral, Publickeytoken=null "
traceoutputoptions= "None" type= " Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener,

Microsoft.Practices.EnterpriseLibrary.Logging, version=2.0.0.0, culture=neutral, Publickeytoken=null "
Name= "formatted EventLog TraceListener"/>
</listeners>
<formatters>
<add template= "Timestamp: {Timestamp} message: {message} Category: {Category} Priority: {Priority} EventId:

{EventID} Severity: {Severity} Title:{title} Machine: {Machine} application Domain: {appDomain} Process Id:

{ProcessID} Process name: {processname} Win32 thread Id: {win32threadid} thread Name: {threadname} Extended Properties:

{Dictionary ({key}-{value})} "
Type= "Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, version=2.0.0.0,

Culture=neutral, Publickeytoken=null "
Name= "Text Formatter"/>
<add template= "Timestamp: {Timestamp} message: {message} Category: {Category} Priority: {Priority} EventId:

{EventID} Severity: {Severity} Title:{title} Machine: {Machine} application Domain: {appDomain} Process Id:

{ProcessID} Process name: {processname} Win32 thread Id: {win32threadid} thread Name: {threadname} Extended Properties:

{Dictionary ({key}-{value})} "
Type= "Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, version=2.0.0.0,

Culture=neutral, Publickeytoken=null "
Name= "SHY520 Formatter"/>
</formatters>
<logFilters>
<add categoryfiltermode= "allowallexceptdenied" type= " Microsoft.Practices.EnterpriseLibrary.Logging.Filters.CategoryFilter,

Microsoft.Practices.EnterpriseLibrary.Logging, version=2.0.0.0, culture=neutral, Publickeytoken=null "
Name= "Category Filter"/>
</logFilters>
<categorySources>
<add switchvalue= "All" Name= "General" >
<listeners>
<add name= "SHY520 Listeners"/>
</listeners>
</add>
</categorySources>
<specialSources>
<allevents switchvalue= "All" name= "all Events"/>
<notprocessed switchvalue= "All" name= "unprocessed Category"/>
<errors switchvalue= "All" name= "Logging errors &amp; Warnings ">
<listeners>
<add name= "formatted EventLog TraceListener"/>
</listeners>
</errors>
</specialSources>
</loggingConfiguration>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.