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 7066423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:04:50+00:00 2026-05-28T05:04:50+00:00

I am building a logging DLL that will simplify EntLib 5 Logging Application Block.

  • 0

I am building a logging DLL that will simplify EntLib 5 Logging Application Block. I am using ConfigurationSourceBuilder to configure the logging for my application. I currently have this:

var configBuilder = new ConfigurationSourceBuilder();

        configBuilder.ConfigureLogging().WithOptions
            .DoNotRevertImpersonation()
            .LogToCategoryNamed("EventLog")
                .WithOptions.SetAsDefaultCategory()
                .SendTo.EventLog("Event Log Listener")
                .FormatWithSharedFormatter("Text Formatter")
                .ToLog("Application")
            .LogToCategoryNamed("Email")
                .SendTo.Email("Email Trace Listener")
                .To(ToEmail)
                .From(fromEmail)
                .WithSubjectStart("Error:")
                .UsingSmtpServer(SmtpServer)
                .UsingSmtpServerPort(SmtpServerPort)
                .Unauthenticated()
                .FormatWithSharedFormatter("Text Formatter")
            .LogToCategoryNamed("LogFile")
                .SendTo.FlatFile("Flat File Trace Listener")
                .ToFile(logFileName)
                .WithHeader("------------------------------")
                .WithFooter("------------------------------")
                .FormatWithSharedFormatter("Text Formatter");

        var configSource = new DictionaryConfigurationSource();
        configBuilder.UpdateConfigurationWithReplace(configSource);
        EnterpriseLibraryContainer.Current = 
            EnterpriseLibraryContainer.CreateDefaultContainer(configSource);

The program will build and I will reference it in the main app. When it goes to set up the configuration it blows up with this error:

InvalidOperationException - The current type,
Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.ILogFormatter, 
is an interface and cannot be constructed. Are you missing a type mapping?

Just in case this matters, the main app is using Unity as an IoC. Do I need to resolve the DLL with Unity?

  • 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-28T05:04:50+00:00Added an answer on May 28, 2026 at 5:04 am

    It looks to me like the issue is that you haven’t actually created a Formatter. You’ve referenced an existing formatter by name with the statement .FormatWithSharedFormatter("Text Formatter").

    If you define a formatter using FormatterBuilder then it should be OK:

    var configBuilder = new ConfigurationSourceBuilder();
    
    configBuilder.ConfigureLogging().WithOptions
    .DoNotRevertImpersonation()
    .LogToCategoryNamed("EventLog")
        .WithOptions.SetAsDefaultCategory()
        .SendTo.EventLog("Event Log Listener")
        .FormatWith(
            new FormatterBuilder()
                .TextFormatterNamed("Text Formatter")
                .UsingTemplate("Timestamp: {timestamp}{newline}Message: {message}{newline}Category: {category}")
            )
        .ToLog("Application")
    .LogToCategoryNamed("Email")
        .SendTo.Email("Email Trace Listener")
        .To(ToEmail)
        .From(fromEmail)
        .WithSubjectStart("Error:")
        .UsingSmtpServer(SmtpServer)
        .UsingSmtpServerPort(SmtpServerPort)
        .Unauthenticated()
        .FormatWithSharedFormatter("Text Formatter")
    .LogToCategoryNamed("LogFile")
        .SendTo.FlatFile("Flat File Trace Listener")
        .ToFile(logFileName)
        .WithHeader("------------------------------")
        .WithFooter("------------------------------")
        .FormatWithSharedFormatter("Text Formatter");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building a C# application using .NET 3.5 that will require logging in to
We have jboss logging enabled in our application. Currently we are using the 'Rotating-file-handler'
I am currently building an ASP.Net-MVC Application using log4net for logging, but the logger
I'm building UI logging into a long-existing ASP.NET enterprise application. I have my own
Im building an application that requires extensive logging of actions of the users, payments,
I am building an application using Javamail. For logging purposes, I set: properties.put(mail.debug, true);
I am building an application using NHibernate. Because I could not add the DLL's
I am currently building an Iphone app that is using storyboards. I know how
I'm building a website where I will have users logging into the site from
I am building an application using cakePHP. Do we have a method where we

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.