Enterprise Lib logging to event log event though no info has been provided

Topics: Logging Application Block
Nov 10, 2009 at 4:54 AM

Hello,

Am facing a weird problem. The Enterprise Library logging application block is logging the information to the event log even if I don’t supply any info to it through the app.config file. Is there any default settings that it takes. 

I encountered this problem when I was planning to write to a log file. The enterprise library never wrote to the log file, but kept on writing to the eventlog. So I removed all the information from the app.config file, but still it wrote the information to the event log.

 Need some urgent help on this.

 Saurabh

Nov 10, 2009 at 5:03 AM

What gets logged in the event log? Is it exactly what you wrote in your code? Or probably an error? Does that app.config file belong to an executable project or a class library?

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Nov 10, 2009 at 5:15 AM

Thanks for the prompt reply.

1. The event log is logged with exactly the same info that is in my code. It does not log any error.

2. The code as well as the config file belong to an executable project. There is no class library.

Nov 10, 2009 at 5:19 AM

When you said that you removed all the information from the app.config file, does it mean that you removed the whole loggingConfiguration section?  Is your api merely a call to Logger.Write?

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Nov 10, 2009 at 5:30 AM

Thats absolutely correct.

I initially had the config info in app.config, to log entries to the event log. Later I wanted to change the destination to a log file (flat file). When i did the changes, they were not getting reflected (the entries were still getting logged to the eventlog).

just for experiment sake, i removed all of the config info pertaining to logging. But it was still logging. Weird i know, but it is happening.

 

My primary aim is that i would be able to switch between the event log and the flat files as my destinations whenever i change the info in the app.config file

Nov 10, 2009 at 5:33 AM

Is this just a simple app? Could you just send it to me, I could have a look at it right now.

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Nov 10, 2009 at 6:53 AM

it is very simple.....following is the source code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Logging;

namespace LoggingDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            LogEntry entry = new LogEntry() { Message = "hello EL" };
            entry.Categories.Add("General");
            Logger.Write(entry);


        }
    }
}

 

and the app.config is having just the parent tags....

thanks a lot....

Nov 10, 2009 at 7:16 AM

It should have thrown an exception with the message "The configuration section for Logging cannot be found in the configuration source." if there was no loggingConfiguration section in your configuration file.  I can't repro your case, could you repro it on a new project? 

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com