Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8651409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:03:51+00:00 2026-06-12T14:03:51+00:00

I have a config file like: <configSections> <section name=loggingConfiguration type=Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35/>

  • 0

I have a config file like:

<configSections>
    <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</configSections>

<loggingConfiguration name="Logging Application Block" tracingEnabled="true" defaultCategory="Tracing" logWarningsWhenNoCategoriesMatch="true">
    <listeners>
        <add listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.SystemDiagnosticsTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" type="System.Diagnostics.ConsoleTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="System Diagnostics Trace Listener"/>
    </listeners>
    <formatters>
        <add template="{message}" type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Text Formatter"/>
    </formatters>
    <categorySources>
          <add switchValue="All" name="AppLog">
    <listeners>
          <add name="System Diagnostics Trace Listener"/>
    </listeners>
  </add>
</categorySources>
<specialSources>
  <allEvents switchValue="All" name="All Events"/>      
  <notProcessed switchValue="All" name="Unprocessed Category"/>
  <errors switchValue="Off" name="Logging Errors &amp; Warnings"/>
</specialSources>

Besides the console listener that I have, I want to define a RollingFlatFileTraceListenerData programmatically:

var listener = new RollingFlatFileTraceListenerData("AppLog", @"c:\log.log", "", "", 0, "yyyyMMdd-hhmm", Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollFileExistsBehavior.Increment, Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollInterval.Hour, TraceOptions.LogicalOperationStack, "Text Formatter");

How can I add my newly defined listener to the list of listeners programmatically?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T14:03:52+00:00Added an answer on June 12, 2026 at 2:03 pm

    In general, in asp.net apps, a simple way to programmatically add TraceListeners is with the diagnostics’ Trace.Listeners.Add() method. I like to do this in my global.asax.cs on Application_Start():

    using D = System.Diagnostics;
    
    ...
    
    protected void Application_Start()
    {
       if (D.Trace.Listeners["MyTraceListener"] == null)
       {
          D.Trace.Listeners.Add(new MyTraceListener("") { Name = "MyTraceListener" });
       }
    
       ...
    
    }
    

    The only reason I check if it’s already in place is because I’ve seen Application_Start() fire more than once, albeit infrequently.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a config file like package com.mypackage.referencedata.config; @Configuration @ComponentScan (com.mypackage.referencedata.*) public class ReferenceDataConfig
I have XML-file with settings like this <?xml version=1.0 encoding=utf-8 ?> <configuration> <configSections> <sectionGroup
I have a rewrite rule in my web.config file like this: <rule name=Public page
I have asp.net web site. I added reference of Microsoft.Practices.EnterpriseLibrary.Logging.dll to the site. in
i have a config file like this: ?xml version=1.0 encoding=utf-8 ? configuration appSettings add
I have a config.php file that creates an array, something like $config = array(
I have a problem, my rake file looks like this: require File.expand_path('../config/application', __FILE__) require
I have a php file that looks like this: <?php include(config.php); // put the
I have a file system structure with symlinks, something like this: folder123 index.php config.php
I have one custom config file. <Students> <student> <Detail Name=abc Class=1st Year> <add key=Main

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.