How to Setup Logging using Enterprise Library in .NET

 

Here is the lines of code you put into the app.config file for the Services and GUI to get logging working using Enterprise Library.  This code is using the Enterprise Library 4.0

I used this in NADP, FBSubmit, and FBEdTrack

 

 

Code Snippet
  1.  <loggingConfiguration name="Logging Application Block" tracingEnabled="true"
  2. defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">
  3.      <listeners>
  4.          <add fileName="c:\logs\FBSubmit\trace.log" header="—————————————-"
  5.   footer="—————————————-" formatter=""
  6.   listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
  7.   traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
  8.   name="FlatFile TraceListener" />
  9.          <add fileName="c:\logs\FBSubmit\trace.log" footer="—————————————-"
  10.   formatter="" header="—————————————-"
  11.   rollFileExistsBehavior="Overwrite" rollInterval="None" rollSizeKB="0"
  12.   timeStampPattern="yyyy-MM-dd" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
  13.   traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
  14.   name="Rolling Flat File Trace Listener" />
  15.      </listeners>
  16.      <formatters>
  17.          <add template="Timestamp: {timestamp} Message: {message} Category: {category} Priority: {priority} EventId: {eventid} Severity: {severity} Title:{title} Machine: {machine} Extended Properties: {dictionary({key} – {value} )}"
  18.   type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
  19.   name="Text Formatter" />
  20.      </formatters>
  21.      <categorySources>
  22.          <add switchValue="All" name="General" />
  23.      </categorySources>
  24.      <specialSources>
  25.          <allEvents switchValue="All" name="All Events">
  26.              <listeners>
  27.                  <add name="FlatFile TraceListener" />
  28.                  <add name="Rolling Flat File Trace Listener" />
  29.              </listeners>
  30.          </allEvents>
  31.          <notProcessed switchValue="All" name="Unprocessed Category" />
  32.          <errors switchValue="All" name="Logging Errors &amp; Warnings" />
  33.      </specialSources>
  34.  </loggingConfiguration>

Tags: , , ,

2 Responses to “How to Setup Logging using Enterprise Library in .NET”

  1. ebook, download, ebook download, filesonic, fileserve, uploading, hotfile, megaupload, rapidshare, filepost, filejungle, uploadstation Says:

    ebook, download, ebook download, filesonic, fileserve, uploading, hotfile, megaupload, rapidshare, filepost, filejungle, uploadstation…

    […]How to Setup Logging using Enterprise Library in .NET « 1-800-The-Nerd's Blog[…]…

  2. free ebook Says:

    free ebook…

    […]How to Setup Logging using Enterprise Library in .NET « 1-800-The-Nerd's Blog[…]…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: