ComponentSpace Trace Listeners Class Library

Trace Listeners Class Library

Introduction provides an overview of the Trace Listeners Class Library.

Installation details the prerequisite system requirements and installation procedures for the Trace Listeners Class Library.

Reference documents the namespaces and classes that constitute the Trace Listeners Class Library.

Examples describes the included example code.

FAQ lists frequently asked questions.

Support describes how to get support.

Send comments on this topic.


Introduction

The standard .NET diagnostic trace files can become unwieldy. Wouldn’t it be nice if trace files could be limited to manageable sizes and automatically cycled? Included is a cyclic file trace listener that extends the System.Diagnostics.TraceListener class. The trace listener is fully configurable from your application’s XML configuration file. Also included are HTTP, SMTP and MSMQ trace listeners. Written in 100% managed C# code, the class library offers .NET developers sophisticated tracing options for their applications.

The cyclic file trace listener writes to a file (e.g. 00000.log) until it reaches a configurable size and then writes to the next file in the sequence (e.g. 00001.log). When you configure the cyclic file trace listener you may specify the folder location for the trace files, the trace file prefix, suffix and starting sequence number. Trace files are written to the specified directory and are named:

<directoryName>\<filePrefix><sequenceNumber><fileSuffix>.

You may also specify the maximum file size as well as the field separator for trace entries, and whether timestamps, process and thread identifiers, and the caller’s class and method name are automatically included with each trace entry. Of course, you may also configure all these properties at runtime from within your code if you choose. In the following example trace entry only the last field was written by the calling application. The trace listener automatically included all other fields.

07/04/2002 9:24:03 AM, 14220/12972, TestTraceListeners.MainForm.buttonTrace_Click, This is test #1.

The HTTP trace listener uploads trace entries to a configured URL. The SMTP trace listener sends trace entries to a configured email address. The MSMQ trace listener puts trace entries on a configured queue.

Features

  • Fully configurable cyclic file trace listener
  • Specify the location, base name and maximum size of the trace files
  • Automatically include a timestamp with your trace entries
  • The process and thread identifier’s may also be automatically included
  • Include the caller’s class and method name with no user code required
  • Also HTTP, SMTP and MSMQ trace listeners
  • 100% managed code written in C#
  • Object oriented design specifically for the .NET framework
  • All error handling through .NET exceptions
  • Comprehensive Visual Studio .NET style documentation
  • VB.NET and C# example source code
  • Includes prompt free email support
  • Royalty free runtime
  • Source code available

Getting Started

  • Install the product in your development environment.
  • Compile and run one of the examples.
  • Refer to the reference section for further details.
  • Modify the XML configuration file for your application.
  • Once completed, distribute the class library with your application.


Installation

To install this product double click the .MSI file and follow the installation steps.

Prerequisites

The Microsoft .NET framework runtime must already be installed on your computer. The Microsoft .NET framework redistributable may be downloaded from msdn.microsoft.com.

You will also need a development environment such as Visual Studio .NET.

Distribution

The class library's runtime is royalty free which means it may be freely distributed with your application. The only file that should be distributed is the class library's DLL.


Reference

The reference section is contained within a separate help file.


Examples

Example code, developed using Microsoft Visual Studio .NET, is included with the product. You will find these projects in sub-directories of the installation directory.

TestTraceListeners
Demonstrates writing tracing events from a C# application. You can change the TestTraceListeners.exe.config file to modify the trace listeners' configuration.
VBTestTraceListeners
Demonstrates writing tracing events from a VB.NET application. You can change the VBTestTraceListeners.exe.config file to modify the trace listeners' configuration.


FAQ

Frequently Asked Questions
  1. I can't build the examples. Why can't the ComponentSpace namespace be found?

    2. The assembly containing the namespace or the project referencing it has been moved. The simplest way to fix this is to re-add the reference to the project by browsing to where the DLL is located (typically the installation directory).

  2. Are the trace listeners thread safe?

    3. Yes. For example, CyclicFileTraceListener ensures that trace entries are not interleaved.

  3. Why am I getting a ConfigurationException?

    4. You need to review the trace listener's configuration. One of the parameters is invalid. The exception's stack trace should provide further information.

  4. Within my configuration file, how do I specify strings within my initializeData XML attribute?

    5. Strings can either be enclosed with single or double quotation marks. This also is true of XML attributes.

    The simplest approach is to use one form of quotation mark for the XML attribute and another for the initializeData string. For example, initializeData="directoryName='c:\logs'" or initializeData='directoryName="c:\logs"'.

    Alternatively you can use the same quotation marks but this means you must use entity references.


Support

For further information, visit us at http://www.componentspace.com or send email to info@componentspace.com.

If have a bug to report or a product enhancement request send email to support@componentspace.com.