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

  • SEARCH
  • Home
  • 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 6721145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:17:42+00:00 2026-05-26T09:17:42+00:00

I have asp.net web site. I added reference of Microsoft.Practices.EnterpriseLibrary.Logging.dll to the site. in

  • 0

I have asp.net web site. I added reference of Microsoft.Practices.EnterpriseLibrary.Logging.dll to the site.

in web.cofig file, I defined like below.

    <?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
  </configSections>
  <loggingConfiguration name="Logging Application Block" tracingEnabled="true"
    defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">
    <listeners>
      <add name="Rolling Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging"
        listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging"
        fileName="C:\Temp\RollingFlatFile.log" footer="----------------------------------------"
        formatter="Text Formatter" header="----------------------------------------"
        rollFileExistsBehavior="Increment" rollInterval="None" rollSizeKB="20"
        timeStampPattern="yyyy-MM-dd" maxArchivedFiles="3" traceOutputOptions="None"
        filter="All" />
      </listeners>
    <formatters>
      <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging"
        template="Timestamp: {timestamp(local)}{tab}Message: {message}{tab}Category: {category}{tab}Priority: {priority}{tab}EventId: {eventid}{tab}ActivityId: {property(ActivityId)}{tab}Severity: {severity}{tab}Title:{title}{tab}"
        name="Brief Format Text" />
      <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging"
        template="Timestamp: {timestamp}{tab}Message: {message}{tab}Category: {category}{tab}Priority: {priority}{tab}EventId: {eventid}{tab}Severity: {severity}{tab}Title: {title}{tab}Activity ID: {property(ActivityId)}{tab}Machine: {localMachine}{tab}App Domain: {localAppDomain}{tab}ProcessId: {localProcessId}{tab}Process Name: {localProcessName}{tab}Thread Name: {threadName}{tab}Win32 ThreadId:{win32ThreadId}{tab}Extended Properties: {dictionary({key} - {value}{tab})}"
        name="Text Formatter" />
    </formatters>
    <logFilters>
      <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.PriorityFilter, Microsoft.Practices.EnterpriseLibrary.Logging"
        minimumPriority="2" maximumPriority="99" name="Priority Filter" />
      <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.LogEnabledFilter, Microsoft.Practices.EnterpriseLibrary.Logging"
        enabled="true" name="LogEnabled Filter" />
      <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.CategoryFilter, Microsoft.Practices.EnterpriseLibrary.Logging"
        categoryFilterMode="AllowAllExceptDenied" name="Category Filter">
        <categoryFilters>
          <add name="BlockedByFilter" />
        </categoryFilters>
      </add>
    </logFilters>
    <categorySources>
      <add switchValue="All" name="Important">
        <listeners>
          <add name="Formatted EventLog TraceListener" />
          <add name="Rolling Flat File Trace Listener" />
        </listeners>
      </add>
    </categorySources>
    <specialSources>
      <allEvents switchValue="All" name="All Events" />
      <notProcessed switchValue="All" name="Unprocessed Category">
        <listeners>
          <add name="UnprocessedFlatFile" />
        </listeners>
      </notProcessed>
      <errors switchValue="All" name="Logging Errors &amp; Warnings">
        <listeners>
          <add name="Formatted EventLog TraceListener" />
        </listeners>
      </errors>
    </specialSources>
  </loggingConfiguration>
</configuration>

When I run the code exception happening below place.

defaultWriter = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();
//Activation error occured while trying to get instance of type LogWriter, key ""

How to resolve this?

  • 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-05-26T09:17:42+00:00Added an answer on May 26, 2026 at 9:17 am

    Your full config references trace listeners that are not defined. This is causing the Enterprise Library runtime to throw a runtime exception when it tries to resolve those references.

    I commented out the unused listeners (and changed the default category to Important) and it is working:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <configSections>
            <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
        </configSections>
        <loggingConfiguration name="Logging Application Block" tracingEnabled="true"
          defaultCategory="Important" logWarningsWhenNoCategoriesMatch="true">
            <listeners>
                <add name="Rolling Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging"
                  listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging"
                  fileName="C:\Temp\RollingFlatFile.log" footer="----------------------------------------"
                  formatter="Text Formatter" header="----------------------------------------"
                  rollFileExistsBehavior="Increment" rollInterval="None" rollSizeKB="20"
                  timeStampPattern="yyyy-MM-dd" maxArchivedFiles="3" traceOutputOptions="None"
                  filter="All" />
            </listeners>
            <formatters>
                <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging"
                  template="Timestamp: {timestamp(local)}{tab}Message: {message}{tab}Category: {category}{tab}Priority: {priority}{tab}EventId: {eventid}{tab}ActivityId: {property(ActivityId)}{tab}Severity: {severity}{tab}Title:{title}{tab}"
                  name="Brief Format Text" />
                <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging"
                  template="Timestamp: {timestamp}{tab}Message: {message}{tab}Category: {category}{tab}Priority: {priority}{tab}EventId: {eventid}{tab}Severity: {severity}{tab}Title: {title}{tab}Activity ID: {property(ActivityId)}{tab}Machine: {localMachine}{tab}App Domain: {localAppDomain}{tab}ProcessId: {localProcessId}{tab}Process Name: {localProcessName}{tab}Thread Name: {threadName}{tab}Win32 ThreadId:{win32ThreadId}{tab}Extended Properties: {dictionary({key} - {value}{tab})}"
                  name="Text Formatter" />
            </formatters>
            <logFilters>
                <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.PriorityFilter, Microsoft.Practices.EnterpriseLibrary.Logging"
                  minimumPriority="2" maximumPriority="99" name="Priority Filter" />
                <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.LogEnabledFilter, Microsoft.Practices.EnterpriseLibrary.Logging"
                  enabled="true" name="LogEnabled Filter" />
                <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.CategoryFilter, Microsoft.Practices.EnterpriseLibrary.Logging"
                  categoryFilterMode="AllowAllExceptDenied" name="Category Filter">
                    <categoryFilters>
                        <add name="BlockedByFilter" />
                    </categoryFilters>
                </add>
            </logFilters>
            <categorySources>
                <add switchValue="All" name="Important">
                    <listeners>
                        <!--<add name="Formatted EventLog TraceListener" />-->
                        <add name="Rolling Flat File Trace Listener" />
                    </listeners>
                </add>
            </categorySources>
            <specialSources>
                <allEvents switchValue="All" name="All Events" />
                <notProcessed switchValue="All" name="Unprocessed Category">
                    <listeners>
                        <!--<add name="UnprocessedFlatFile" />-->
                    </listeners>
                </notProcessed>
                <errors switchValue="All" name="Logging Errors &amp; Warnings">
                    <listeners>
                        <!--<add name="Formatted EventLog TraceListener" />-->
                    </listeners>
                </errors>
            </specialSources>
        </loggingConfiguration>
    </configuration>
    

    The clue is in the inner exception. At the end of the InnerException.Message it says:

    Resolving System.Diagnostics.TraceListener,Formatted EventLog
    TraceListener

    The above config is in app.config. Then Program.cs contains:

    class Program
    {
        static void Main(string[] args)
        {
            LogWriter logWriter = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();
            logWriter.Write("Test");
         }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have added a service reference to my asp.net web application (originally it was
I have a asp.net web site that was developed on the .Net Framework v2
I have an ASP.Net web site (ASPX and ASMX pages) with a single web.config
I have a asp.net web site built with .net 2.0 framework. we recently purchased
I have an ASP.NET Web Forms web site. It has a page inside of
I have an ASP.NET web site with something similar to the following code: .aspx
I have an ASP.NET MVC web site. I have many actions which require authentication
In my ASP.Net Web Site I have a button.When I click the button and
I have an ASP.NET 3.5 Web Site using the standard SQL Membership Provider. The
We have a legacy ASP.NET web site (not web application, so I can freely

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.