Logging QuickStart

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 Logging QuickStart demonstrates the following scenarios:

The QuickStart uses a top-level handler to catch any exceptions that occur during any of the scenarios. The handler displays a dialog box with the exception message.

System Requirements

To build and run this QuickStart, you need the following:

  • Microsoft Windows XP Professional, Windows Server 2003, or Windows Vista operating system
  • Microsoft .NET Framework, version 2.0
  • Microsoft Visual Studio 2005 development system

The QuickStart does not require you to perform any setup procedures before building and running the application.

Building the QuickStart

The QuickStart ships as source code, which means that you must compile it before running it. You use Visual Studio to build the QuickStart.

To build the Logging QuickStart

  1. Ensure the Enterprise Library Source Code has been installed
  2. Open the Enterprise Library Source Code folder from Windows Explorer, or from the Start Menu shortcut: on the taskbar, click Start, point to All Programs, point to Microsoft patterns and practices, point to Enterprise Library 3.1 – May 2007 and select Enterprise Library 3.1 Source Folder.
  3. Open the QuickStarts folder, then Logging, then CS (for C#) or VB (for Visual Basic .NET)
  4. Double-click the LoggingQuickStart.sln icon.
  5. Visual Studio opens, displaying the solution file. On the menu, click Build.
  6. Click Rebuild Solution. By default, this is a debug build.
  7. Press F5 to run the QuickStart.

QuickStart Configuration

The walkthroughs in the Logging QuickStart are shipped with a defined configuration, which is included in the App.config file. This file is located in the same folder as the QuickStart project file.

To change or view these settings, use the Enterprise Library Configuration Console to open the App.config file in the directory that contains the QuickStart project file. The App.config file contains the configuration data.

Each time you build the code, Visual Studio copies the App.config file to the output directory for the project (the same directory where the QuickStart executable is created), and renames it to LoggingQuickStart.exe.config.

This means that if you want to use the configuration console to change any of the configuration settings, such as the category filter, and you are planning to rebuild the solution, you must change the settings by opening the App.config file located in the QuickStart source directory. You can change the application configuration by opening the LoggingQuickStart.exe.config file with the Enterprise Library Configuration Console. However, these changes will be overwritten during the next successful build.

The default configuration for the Logging QuickStart has the following attributes:

  • General settings:

    Tracing is enabled.

    The default category is General.

  • Filters:

    The category filter will allow all categories except UI Events.

    The priority filter will only allow events with a priority value of 2 or higher

  • Categories:

    Events in category Data Access Events are delivered to the Flat File Destination listener.

    Events in category Debugare delivered to the Debug Destination listener.

    Events in category Generalare delivered to the Event Log Destination listener.

    Events in category Troubleshootingare delivered to the Event Log Destination listener.

    Events in category UI Events are delivered to the Flat File Destination listener.

    Events in category Trace are delivered to the Flat File Destination listener.

  • Special sources:

    Events that occur due to an error are delivered to the Event Log Destination.

  • Listeners:

    The Event Log Destination uses the Text Formatter to format the message and writes the result to the Application Event Log.

    The Flat File Destination uses the Text Formatter to format the message and writes the result to the file trace.log.

    The Debug Destination uses the Text Formatter to format the message and writes the result to the Visual Studio Output Window.

  • Formatters:

    The Text Formatter constructs a string with name value pairs for the LogEvent 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.