Enterprise Library Exception Handling 6.0 XML Logging not writing File - c#

I'm trying to setup the Enterprise Library Exception Handling 6.0 to log errors using the XmlExceptionFormatter in the Enterprise Library Logging Application Block. I'm not receiving any errors, and I can get the Logging to work by itself.
Here is my App.config from the console application I'm testing from:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<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" />
<section name="exceptionHandling"
type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
</configSections>
<loggingConfiguration name="Logging Application Block"
tracingEnabled="false"
defaultCategory="General"
logWarningsWhenNoCategoriesMatch="true">
<listeners>
<add name="XML Trace Listener"
type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.XmlTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.XmlTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
fileName="C:\logs\TestDriver-XML.log"
traceOutputOptions="None" />
</listeners>
<categorySources>
<add switchValue="All" name="General">
<listeners>
<add name="XML Trace Listener" />
</listeners>
</add>
</categorySources>
<specialSources>
<allEvents switchValue="All" name="All Events">
<listeners>
<add name="XML Trace Listener" />
</listeners>
</allEvents>
<notProcessed switchValue="All" name="Unprocessed Category">
<listeners>
<add name="XML Trace Listener" />
</listeners>
</notProcessed>
<errors switchValue="All" name="Logging Errors & Warnings">
<listeners>
<add name="XML Trace Listener" />
</listeners>
</errors>
</specialSources>
</loggingConfiguration>
<exceptionHandling>
<exceptionPolicies>
<add name="Policy">
<exceptionTypes>
<add name="All Exceptions"
type="System.Exception, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
postHandlingAction="None">
<exceptionHandlers>
<add name="Logging Exception Handler"
type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
logCategory="General"
eventId="100"
severity="Error"
title="Enterprise Library Exception Handling"
formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.XmlExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
priority="0" />
</exceptionHandlers>
</add>
</exceptionTypes>
</add>
</exceptionPolicies>
</exceptionHandling>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
My test is:
class Program
{
public static void Main(string[] args)
{
TestExceptionManager();
Console.ReadLine();
}
private static void TestExceptionManager()
{
ExceptionManager exceptionManager = new ExceptionManager();
exceptionManager.Process(MyExceptionCode, "Policy");
}
private static void MyExceptionCode()
{
throw new Exception("A basic Exception");
}
}
Any suggestions to get this to log correctly?

In version 6 you need to use the factory method, updated example:
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling;
using Microsoft.Practices.EnterpriseLibrary.Logging;
using System;
namespace ExceptionHandlingExamples
{
class Program
{
public static void Main(string[] args)
{
try
{
TestExceptionManager();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
Console.ReadLine();
}
private static void TestExceptionManager()
{
IConfigurationSource config = ConfigurationSourceFactory.Create();
ExceptionPolicyFactory factory = new ExceptionPolicyFactory(config);
Logger.SetLogWriter(new LogWriterFactory().Create());
ExceptionManager exceptionManager = factory.CreateManager();
exceptionManager.Process(MyExceptionCode, "Policy");
}
private static void MyExceptionCode()
{
throw new Exception("A basic Exception");
}
}
}

Related

Microsoft EnterpriseLibrary Logging : Logs are not getting generated

I am working on ASP.net MVC project and need to LOG entries in TEXT file using Microsoft.Practices.EnterpriseLibrary.Logging i.e. Microsoft Enterprise Library 5.0.
Problem: LOGGING is not working. I am writing logs in a text file but no entries are going to text file. I have mentioned code snippet of configuration file and of Controller as mentioned below.
I need to use M S Enterprise Library only.
Please suggest any working solution of this issue.
Code Snippet:
Web.config
<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="false" />
</configSections>
<loggingConfiguration name="Logging Application Block" tracingEnabled="true" defaultCategory="Architecture" logWarningsWhenNoCategoriesMatch="false" revertImpersonation="false">
<listeners>
<add name="Event Log Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
source="Enterprise Library Logging" formatter="Text Formatter"
log="LuisLogging" machineName="." traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ThreadId, Callstack" />
<add name="Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
fileName="./File/loggingLuis.log" formatter="Text Formatter" />
</listeners>
<formatters>
<add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
template="Timestamp: {timestamp}{newline}
Message: {message}{newline}
Category: {category}{newline}
Priority: {priority}{newline}
EventId: {eventid}{newline}
Severity: {severity}{newline}
Title:{title}{newline}
Machine: {localMachine}{newline}
App Domain: {localAppDomain}{newline}
ProcessId: {localProcessId}{newline}
Process Name: {localProcessName}{newline}
Thread Name: {threadName}{newline}
Win32 ThreadId:{win32ThreadId}{newline}
Extended Properties: {dictionary({key} - {value}{newline})}"
name="Text Formatter" />
</formatters>
<categorySources>
<add switchValue="All" name="General">
<listeners>
<add name="Flat File Trace Listener" />
</listeners>
</add>
</categorySources>
<specialSources>
<allEvents switchValue="All" name="All Events" />
<notProcessed switchValue="All" name="Unprocessed Category" />
<errors switchValue="All" name="Logging Errors & Warnings">
<listeners>
<add name="Flat File Trace Listener" />
</listeners>
</errors>
</specialSources>
</loggingConfiguration>
Controller Code :
using Microsoft.Practices.EnterpriseLibrary.Logging;
using Microsoft.Practices.Unity;
using Microsoft.Practices.EnterpriseLibrary.Common;
try
{
var fileContent = Request.Files["HeaderTemplateView"];
Logger.Write("Hello World another time: Start");
Logger.Write("Hello World another time: End");
LogWriterFactory logWriterFactory = new LogWriterFactory();
LogWriter logWriter = logWriterFactory.Create();
logWriter.Write("Hello by LogWriter");
}
catch (Exception ex)
{
Logger.Write(string.Format(System.Globalization.CultureInfo.CurrentCulture, "Error Message:{0} , InnerEx : {1}", ex.Message, (ex.InnerException != null) ? ex.InnerException.ToString() : string.Empty), "UploadServiceError");
}

Migrate Enterprise Library 5 to 6

Trying to move from Enterprise Library 5.0 to 6.0, I ran into some troubles. Maybe this will help others.
Following configuration is an example for (silent) exception logging to database:
<configSections>
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging" requirePermission="true" />
<section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling" requirePermission="true" />
</configSections>
<loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
<listeners>
<add name="Database Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging.Database"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database"
databaseInstanceName="LogContext" writeLogStoredProcName="WriteLog"
addCategoryStoredProcName="AddCategory" formatter="Text Formatter" />
</listeners>
<formatters>
<add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging"
template="Timestamp: {timestamp}{newline}..."
name="Text Formatter" />
</formatters>
<categorySources>
<add switchValue="All" name="Exception">
<listeners>
<add name="Database Trace Listener" />
</listeners>
</add>
</categorySources>
</loggingConfiguration>
<exceptionHandling>
<exceptionPolicies>
<add name="UiPolicy">
<exceptionTypes>
<add name="All Exceptions" type="System.Exception, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
postHandlingAction="None">
<exceptionHandlers>
<add name="Logging Exception Handler" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging"
logCategory="Exception" eventId="100" severity="Error" title="Enterprise Library Exception Handling"
formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling"
priority="0" />
</exceptionHandlers>
</add>
</exceptionTypes>
</add>
</exceptionPolicies>
</exceptionHandling>
I'm using following assemblies with version 5.0.414.0:
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging
Microsoft.Practices.EnterpriseLibrary.Logging
Microsoft.Practices.EnterpriseLibrary.Logging.Database
With Enterprise Library 5.0 using all this within a asp.net MVC app is as easy as:
// ...
catch (Exception ex)
{
if (ExceptionPolicy.HandleException(ex, "UiPolicy")) throw;
// do something else
}
After upgrading the assemblies to Enterprise Library 6.0, I get following exception message:
Must set an ExceptionManager in the ExceptionPolicy class using the SetExceptionManager method.
So, what to do?
Step by Step
To get rid of this exception (credit to Randy's answer), one has to go with ExceptionManager, in my case via factory. I use this in global.asax' Application_Start() method:
protected void Application_Start()
{
IConfigurationSource source = ConfigurationSourceFactory.Create();
var exceptionPolicyFactory = new ExceptionPolicyFactory(source);
var exceptionManager = exceptionPolicyFactory.CreateManager();
ExceptionPolicy.SetExceptionManager(exceptionManager);
}
But with my handling and logging settings this was only half way. I now got the following exception at exceptionPolicyFactory.CreateManager()
The LogWriter has not been set for the Logger static class. Set it invoking the Logger.SetLogWriter method.
For this to go away I added
var logwriterFactory = new LogWriterFactory(source);
var logWriter = logwriterFactory.Create();
Logger.SetLogWriter(logWriter);
Now it said
Database provider factory not set for the static DatabaseFactory. Set a provider factory invoking the DatabaseFactory.SetProviderFactory method or by specifying custom mappings by calling the DatabaseFactory.SetDatabases method.
on logwriterFactory.Create(). So there was one more thing to add:
DatabaseFactory.SetDatabaseProviderFactory(new DatabaseProviderFactory(source));
Complete Solution
All together my Application_Start() now is
protected void Application_Start()
{
IConfigurationSource source = ConfigurationSourceFactory.Create();
DatabaseFactory.SetDatabaseProviderFactory(new DatabaseProviderFactory(source));
var logwriterFactory = new LogWriterFactory(source);
var logWriter = logwriterFactory.Create();
Logger.SetLogWriter(logWriter);
var exceptionPolicyFactory = new ExceptionPolicyFactory(source);
var exceptionManager = exceptionPolicyFactory.CreateManager();
ExceptionPolicy.SetExceptionManager(exceptionManager);
}
while the configuration and the actual exception handling code stays the same:
ExceptionPolicy.HandleException(exceptionToHandle, "UiPolicy");

Enterprise Library logging to filter by category like some value

I've been looking around for documentation regarding enterprise library 5.0 logging and filtering but couldn't find anything related to my scenario, outside of the enterprise library CHM.
I have a few types of categories being logged and I want to filter the logging to pick up only certain categories.
Say I have these categories General,Turtle, Rhino.A, Rhino.B, Rhino.C etc lots of Rhinos.
I want to only pick up categories like Rhino.__
what I believe I did was filter for anything not General or Turtle, however I rather try to pick up anything that's like Rhino.__
Even some documentation about this would be helpful.
This is my current config.
<loggingConfiguration name="" tracingEnabled="true" defaultCategory="General" logWarningsWhenNoCategoriesMatch="false">
<listeners>
<add name="Event Log Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" source="Enterprise Library Logging" formatter="Text Formatter" log="" machineName="." traceOutputOptions="None" />
<add name="Rolling Flat File Trace Listener"
type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
fileName="AppLog.log"
formatter="Short Text Formatter" header="------------------------------------------------------" footer="------------------------------------------------------"
rollInterval="Day" rollSizeKB="1024"
timeStampPattern="yyyy-MM-dd"
rollFileExistsBehavior="Increment"
traceOutputOptions="LogicalOperationStack, DateTime" />
</listeners>
<formatters>
<add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" template="Timestamp: {timestamp(local)}{newline}App Domain: {localAppDomain}{newline}Machine: {localMachine}{newline}Title:{title}{newline}Severity: {severity}{tab}Message: {message}{newline}Category: {category}{newline}ProcessId: {localProcessId}{tab}Process Name: {localProcessName}{newline}Thread Name: {threadName}{tab}ThreadId:{win32ThreadId}
" name="Text Formatter" />
</formatters>
<logFilters>
<add type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.CategoryFilter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
categoryFilterMode="AllowAllExceptDenied" name="Category Filter">
<categoryFilters>
<add name="General" />
<add name="Turtle" />
</categoryFilters>
</add>
</logFilters>
<categorySources>
<add switchValue="All" name="General" />
<add switchValue="All" name="Turtle" />
</categorySources>
<specialSources>
<allEvents switchValue="All" name="All Events" />
<notProcessed switchValue="All" name="Unprocessed Category">
<listeners>
<add name="Rolling Flat File Trace Listener" />
</listeners>
</notProcessed>
<errors switchValue="All" name="Logging Errors & Warnings">
<listeners>
<add name="Event Log Listener" />
</listeners>
</errors>
</specialSources>
</loggingConfiguration>
The filtering looks as so, and I'm capturing everything but General and Turtle, which works but seems a little concerning because I rather capture only things like Rhino.__ to be absolutely sure the log is clean of other categories.
<logFilters>
<add type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.CategoryFilter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
categoryFilterMode="AllowAllExceptDenied" name="Category Filter">
<categoryFilters>
<add name="General" />
<add name="Turtle" />
</categoryFilters>
</add>
</logFilters>
<categorySources>
<add switchValue="All" name="General" />
<add switchValue="All" name="Turtle" />
</categorySources>
It appears that Enterprise Library does not support your scenario directly. You may have to implement a Custom Logging Filter.
Here is what it might look like (this is untested code):
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Logging;
using Microsoft.Practices.EnterpriseLibrary.Logging.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Logging.Filters;
using System;
using System.Linq;
[ConfigurationElementType(typeof (CustomLogFilterData))]
public class RhinoFilter : LogFilter
{
public RhinoFilter(string name)
: base(name)
{
}
public RhinoFilter(NameValueCollection settings)
: this("RhinoFilter")
{
}
public override bool Filter(LogEntry log)
{
return log.Categories.Any(x => x.StartsWith("Rhino."));
}
}

How to add RollingFlatFileTraceListenerData programmatically

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 & 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?
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.

where enterprise library 4.1 logger, logs?

I have done its configurations using configuration wizard but I couldn't understand where it is logging messages. I even see app.config file but couldn't find any logging source.
Please guide me where it does logs and how I can check that log.
Here is my config file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</configSections>
<loggingConfiguration name="Logging Application Block" tracingEnabled="true"
defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">
<listeners>
<add fileName="C:\Users\Administrator\Desktop\EAMS\trace.log"
header="----------------------------------------" footer="----------------------------------------"
formatter="" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
traceOutputOptions="LogicalOperationStack" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="FlatFile TraceListener" />
<add source="Enterprise Library Logging" formatter="Text Formatter"
log="Application" machineName="" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
traceOutputOptions="LogicalOperationStack" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="Formatted EventLog TraceListener" />
</listeners>
<formatters>
<add template="Timestamp: {timestamp}
Message: {message}
Category: {category}
Priority: {priority}
EventId: {eventid}
Severity: {severity}
Title:{title}
Machine: {machine}
Application Domain: {appDomain}
Process Id: {processId}
Process Name: {processName}
Win32 Thread Id: {win32ThreadId}
Thread Name: {threadName}
Extended Properties: {dictionary({key} - {value}
)}"
type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="Text Formatter" />
</formatters>
<categorySources>
<add switchValue="All" name="General">
<listeners>
<add name="Formatted EventLog TraceListener" />
</listeners>
</add>
</categorySources>
<specialSources>
<allEvents switchValue="All" name="All Events" />
<notProcessed switchValue="All" name="Unprocessed Category" />
<errors switchValue="All" name="Logging Errors & Warnings">
<listeners>
<add name="Formatted EventLog TraceListener" />
</listeners>
</errors>
</specialSources>
</loggingConfiguration>
<connectionStrings>
<add name="ConnectionString" connectionString="Data Source=YAWARLAPTOP;Initial Catalog=EAMS;Integrated Security=true"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
You need to configure one or more Trace Listeners. Also see Configuration Overview
Edit 1
Thank you for an example of you config file. You are logging your messages into Application Event Log. Please open this Event Log as you normally do and you'll be able to see your messages in there.
Edit 2
In your original question you asked where the messages are logged. This answer has been provided to you. When you write a question, it's better to specify upfront, what are you trying to achieve. To log into a flat file, after you configured a flat file listener you need to add reference to this listener to your sources. See how it's done with the Event Log trace listener in your example and follow the same pattern.
This is correct.
Authentication has been added to the email tracelistener in v5.0.
If you must use v4.1, there's a version of the email tracelistener with authentication on EntLibContrib.

Categories