Click here to Skip to main content
15,886,137 members
Articles / Web Development / ASP.NET

Port Writer Trace Listener for .NET Applications

Rate me:
Please Sign up or sign in to vote.
4.60/5 (11 votes)
12 Aug 2007CPOL11 min read 66.2K   1.6K   55  
A Trace Listener class writing Trace Messages to a UDP port. Also provided is a WinForm application called TraceView to view the Trace Messages sent by the Trace Listener.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace PerformanceSolutions.WinForms
{
    public partial class FilterDlg : Form
    {
        private TraceFilter CurrentTraceFilter = null;
        public FilterDlg()
        {
            InitializeComponent();
        }

        public TraceFilter Filter
        {
            get { return CurrentTraceFilter; }
            set { CurrentTraceFilter = value; }
        }

        private void FilterDlg_Load(object sender, EventArgs e)
        {
            this.chkCritical.Checked = CurrentTraceFilter.Critical;
            this.chkError.Checked = CurrentTraceFilter.Error;
            this.chkAspDotNet.Checked = CurrentTraceFilter.AspDotNet;
            this.chkInformation.Checked = CurrentTraceFilter.Information;
            this.chkWarning.Checked = CurrentTraceFilter.Warning;
            this.txtKeyword.Text = CurrentTraceFilter.Keywords;
            this.cboField.SelectedIndex = (int)CurrentTraceFilter.Field;
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            CurrentTraceFilter.Critical=this.chkCritical.Checked;
            CurrentTraceFilter.Error = this.chkError.Checked;
            CurrentTraceFilter.AspDotNet = this.chkAspDotNet.Checked;
            CurrentTraceFilter.Information = this.chkInformation.Checked;
            CurrentTraceFilter.Warning=this.chkWarning.Checked;
            CurrentTraceFilter.Keywords = this.txtKeyword.Text;
            CurrentTraceFilter.Field=(TraceFilter.TraceField) this.cboField.SelectedIndex;
            this.Close();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void chkAspDotNet_CheckedChanged(object sender, EventArgs e)
        {
            if (this.chkAspDotNet.Checked)
            {
                this.chkCritical.Checked = true;
                this.chkCritical.Enabled = false;
                this.chkError.Checked = true;
                this.chkError.Enabled = false;
                this.chkInformation.Checked = true;
                this.chkInformation.Enabled = false;
                this.chkWarning.Checked = true;
                this.chkWarning.Enabled = false;
            }
            else
            {
                this.chkCritical.Checked = true;
                this.chkCritical.Enabled = true;
                this.chkError.Checked = true;
                this.chkError.Enabled = true;
                this.chkInformation.Checked = true;
                this.chkInformation.Enabled = true;
                this.chkWarning.Checked = true;
                this.chkWarning.Enabled = true;
            }
        }
	
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions