C
coconet
Running Vista x64. Visual Studio 2008 Web Application Project.
I installed Enterprise Library 3.1, built it, and modified the
web.config. I want to log everything to a text file, and log
everything that is a Warning or more severe to the Application Event
Log.
Everything properly logs to the file, but nothing is in the Event Log.
Why?
My C# Code:
LogEntry logEntry = new LogEntry();
logEntry.EventId = 100;
logEntry.Categories.Add( "TestCategory" );
logEntry.Priority = 1;
logEntry.Severity = TraceEventType.Error;
logEntry.Message = "qwerty";
logEntry.Title = "asdfgh";
logEntry.MachineName = Environment.MachineName;
Logger.Write( logEntry );
In my web.config:
<loggingConfiguration name="Logging Application Block"
tracingEnabled="true" defaultCategory=""
logWarningsWhenNoCategoriesMatch="true">
<listeners>
<add
fileName="c:\trace.log"
header="----------------------------------------"
footer="----------------------------------------"
formatter="Text Formatter"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData,
Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
traceOutputOptions="None"
type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener,
Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
name="FlatFile TraceListener"
/>
<add
source="Source00001"
formatter="Text Formatter"
log="Application"
machineName=""
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData,
Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
traceOutputOptions="None"
type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener,
Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
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=3.1.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
name="Text Formatter"
/>
</formatters>
<specialSources>
<allEvents
switchValue="All"
name="All Events">
<listeners>
<add
name="FlatFile TraceListener"
/>
</listeners>
</allEvents>
<notProcessed
switchValue="All"
name="Unprocessed Category"
/>
<errors
switchValue="Error"
name="Logging Errors & Warnings">
<listeners>
<add
name="Formatted EventLog TraceListener"
/>
</listeners>
</errors>
</specialSources>
</loggingConfiguration>
I installed Enterprise Library 3.1, built it, and modified the
web.config. I want to log everything to a text file, and log
everything that is a Warning or more severe to the Application Event
Log.
Everything properly logs to the file, but nothing is in the Event Log.
Why?
My C# Code:
LogEntry logEntry = new LogEntry();
logEntry.EventId = 100;
logEntry.Categories.Add( "TestCategory" );
logEntry.Priority = 1;
logEntry.Severity = TraceEventType.Error;
logEntry.Message = "qwerty";
logEntry.Title = "asdfgh";
logEntry.MachineName = Environment.MachineName;
Logger.Write( logEntry );
In my web.config:
<loggingConfiguration name="Logging Application Block"
tracingEnabled="true" defaultCategory=""
logWarningsWhenNoCategoriesMatch="true">
<listeners>
<add
fileName="c:\trace.log"
header="----------------------------------------"
footer="----------------------------------------"
formatter="Text Formatter"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData,
Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
traceOutputOptions="None"
type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener,
Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
name="FlatFile TraceListener"
/>
<add
source="Source00001"
formatter="Text Formatter"
log="Application"
machineName=""
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData,
Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
traceOutputOptions="None"
type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener,
Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
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=3.1.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
name="Text Formatter"
/>
</formatters>
<specialSources>
<allEvents
switchValue="All"
name="All Events">
<listeners>
<add
name="FlatFile TraceListener"
/>
</listeners>
</allEvents>
<notProcessed
switchValue="All"
name="Unprocessed Category"
/>
<errors
switchValue="Error"
name="Logging Errors & Warnings">
<listeners>
<add
name="Formatted EventLog TraceListener"
/>
</listeners>
</errors>
</specialSources>
</loggingConfiguration>