Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The configuration section for Logging cannot be found in the configuration source

I get the following exception. I am using Enterprise Library 6.0 Application Logging Block.

    System.InvalidOperationException was unhandled by user code
  HResult=-2146233079
  Message=The configuration section for Logging cannot be found in the configuration source.
  Source=Microsoft.Practices.EnterpriseLibrary.Logging
  StackTrace:
       at Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterFactory.LogWriterConfigurationBuilder.Create()
       at Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterFactory.Create()
       at Logger..ctor() in \MBSLogger.cs:line 19
       at EventLoggingTest.test_log_simple_exception() in c:\Users\Vinay.Joseph\Documents\Visual Studio 2013\EventLoggingTest.cs:line 20
  InnerException: 

The code base is below.

       IConfigurationSource configurationSource = ConfigurationSourceFactory.Create();
        LogWriterFactory logWriterFactory = new LogWriterFactory(configurationSource);
        Logger.SetLogWriter(logWriterFactory.Create());


        if (!Logger.IsLoggingEnabled())
        {

        }
        else { 
            Logger.Write(new LogEntry(){
                Severity = System.Diagnostics.TraceEventType.Information,
                TimeStamp = DateTime.Now,
                Message = "Hello World"
            });
        }

Please tell me where I am going wrong.

like image 650
Vinay Joseph Avatar asked Jan 23 '15 06:01

Vinay Joseph


1 Answers

What does the app/web.config look like? Do you have the logging configuration setup?

<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
like image 142
Lance Avatar answered Nov 05 '22 19:11

Lance