Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Logging Application Block Not Writing to Vista Event Log

Reply
Thread Tools

Logging Application Block Not Writing to Vista Event Log

 
 
coconet
Guest
Posts: n/a
 
      02-06-2008

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.EnterpriseLi brary.Logging.Configuration.FlatFileTraceListenerD ata,
Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
traceOutputOptions="None"
type="Microsoft.Practices.EnterpriseLibrary.Loggin g.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.EnterpriseLi brary.Logging.Configuration.FormattedEventLogTrace ListenerData,
Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
traceOutputOptions="None"

type="Microsoft.Practices.EnterpriseLibrary.Loggin g.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}&#xD;&#xA;Message:
{message}&#xD;&#xA;Category: {category}&#xD;&#xA;Priority:
{priority}&#xD;&#xA;EventId: {eventid}&#xD;&#xA;Severity:
{severity}&#xD;&#xA;Title:{title}&#xD;&#xA;Machine :
{machine}&#xD;&#xA;Application Domain: {appDomain}&#xD;&#xA;Process
Id: {processId}&#xD;&#xA;Process Name: {processName}&#xD;&#xA;Win32
Thread Id: {win32ThreadId}&#xD;&#xA;Thread Name:
{threadName}&#xD;&#xA;Extended Properties: {dictionary({key} -
{value}&#xD;&#xA}"

type="Microsoft.Practices.EnterpriseLibrary.Loggin g.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 &amp; Warnings">
<listeners>
<add
name="Formatted EventLog TraceListener"
/>
</listeners>
</errors>
</specialSources>
</loggingConfiguration>




 
Reply With Quote
 
 
 
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      02-07-2008

Hi ,

From your description, you're encountering some problem to use Logging
Application Block to write entry into eventlog on a Vista x64 box ,correct?

Since you're developing an ASP.NET web applicaiton, are you using the VS
IDE's built-in test server or host the application in IIS? I suggest you
try the following things first:

** change the listenter setting and also let EventLogListener to log all
the messages(not only high severity ones)

** in your ASP.NET application, use normal .NET EventLog API to log into
the same EventSource to see whether it works.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



This posting is provided "AS IS" with no warranties, and confers no rights.





--------------------
>From: coconet <(E-Mail Removed)>
>Newsgroups: microsoft.public.dotnet.framework.aspnet
>Subject: Logging Application Block Not Writing to Vista Event Log
>Date: Wed, 06 Feb 2008 13:59:17 -0500


>
>
>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.EnterpriseL ibrary.Logging.Configurati

on.FlatFileTraceListenerData,
>Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
>Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
> traceOutputOptions="None"
>type="Microsoft.Practices.EnterpriseLibrary.Loggi ng.TraceListeners.FlatFile

TraceListener,
>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.EnterpriseL ibrary.Logging.Configurati

on.FormattedEventLogTraceListenerData,
>Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
>Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
> traceOutputOptions="None"
>
>type="Microsoft.Practices.EnterpriseLibrary.Loggi ng.TraceListeners.Formatte

dEventLogTraceListener,
>Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
>Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
> name="Formatted EventLog TraceListener"
>/>
></listeners>
><formatters>
><add
> template="Timestamp: {timestamp}&#xD;&#xA;Message:
>{message}&#xD;&#xA;Category: {category}&#xD;&#xA;Priority:
>{priority}&#xD;&#xA;EventId: {eventid}&#xD;&#xA;Severity:
>{severity}&#xD;&#xA;Title:{title}&#xD;&#xA;Machin e:
>{machine}&#xD;&#xA;Application Domain: {appDomain}&#xD;&#xA;Process
>Id: {processId}&#xD;&#xA;Process Name: {processName}&#xD;&#xA;Win32
>Thread Id: {win32ThreadId}&#xD;&#xA;Thread Name:
>{threadName}&#xD;&#xA;Extended Properties: {dictionary({key} -
>{value}&#xD;&#xA}"
>
>type="Microsoft.Practices.EnterpriseLibrary.Loggi ng.Formatters.TextFormatte

r,
>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 &amp; Warnings">
><listeners>
><add
> name="Formatted EventLog TraceListener"
>/>
></listeners>
></errors>
></specialSources>
></loggingConfiguration>
>
>
>
>
>


 
Reply With Quote
 
 
 
 
coconet
Guest
Posts: n/a
 
      02-07-2008
Please provide sample C# code or web.config text so I can test,
thanks.


On Thu, 07 Feb 2008 04:09:04 GMT, http://www.velocityreviews.com/forums/(E-Mail Removed) (Steven
Cheng[MSFT]) wrote:

>
>Hi ,
>
>From your description, you're encountering some problem to use Logging
>Application Block to write entry into eventlog on a Vista x64 box ,correct?
>
>Since you're developing an ASP.NET web applicaiton, are you using the VS
>IDE's built-in test server or host the application in IIS? I suggest you
>try the following things first:
>
>** change the listenter setting and also let EventLogListener to log all
>the messages(not only high severity ones)
>
>** in your ASP.NET application, use normal .NET EventLog API to log into
>the same EventSource to see whether it works.
>
>Sincerely,
>
>Steven Cheng
>
>Microsoft MSDN Online Support Lead
>
>
>
>This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
>
>
>
>--------------------
>>From: coconet <(E-Mail Removed)>
>>Newsgroups: microsoft.public.dotnet.framework.aspnet
>>Subject: Logging Application Block Not Writing to Vista Event Log
>>Date: Wed, 06 Feb 2008 13:59:17 -0500

>
>>
>>
>>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.Enterprise Library.Logging.Configurati

>on.FlatFileTraceListenerData,
>>Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
>>Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
>> traceOutputOptions="None"
>>type="Microsoft.Practices.EnterpriseLibrary.Logg ing.TraceListeners.FlatFile

>TraceListener,
>>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.Enterprise Library.Logging.Configurati

>on.FormattedEventLogTraceListenerData,
>>Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
>>Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
>> traceOutputOptions="None"
>>
>>type="Microsoft.Practices.EnterpriseLibrary.Logg ing.TraceListeners.Formatte

>dEventLogTraceListener,
>>Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
>>Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
>> name="Formatted EventLog TraceListener"
>>/>
>></listeners>
>><formatters>
>><add
>> template="Timestamp: {timestamp}&#xD;&#xA;Message:
>>{message}&#xD;&#xA;Category: {category}&#xD;&#xA;Priority:
>>{priority}&#xD;&#xA;EventId: {eventid}&#xD;&#xA;Severity:
>>{severity}&#xD;&#xA;Title:{title}&#xD;&#xA;Machi ne:
>>{machine}&#xD;&#xA;Application Domain: {appDomain}&#xD;&#xA;Process
>>Id: {processId}&#xD;&#xA;Process Name: {processName}&#xD;&#xA;Win32
>>Thread Id: {win32ThreadId}&#xD;&#xA;Thread Name:
>>{threadName}&#xD;&#xA;Extended Properties: {dictionary({key} -
>>{value}&#xD;&#xA}"
>>
>>type="Microsoft.Practices.EnterpriseLibrary.Logg ing.Formatters.TextFormatte

>r,
>>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 &amp; Warnings">
>><listeners>
>><add
>> name="Formatted EventLog TraceListener"
>>/>
>></listeners>
>></errors>
>></specialSources>
>></loggingConfiguration>
>>
>>
>>
>>
>>


 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      02-08-2008
Thanks for your reply Coconet,

The code to manually write an EventLog entry is quite simple, here is a
function doing it:

========================
private void btnWriteEventLog_Click(object sender, EventArgs e)
{
string source = "my App EventSource";
string log = "Application";
string message = "require more gas!";

if (!EventLog.SourceExists(source))
{
EventLog.CreateEventSource(source, log);
}

EventLog.WriteEntry(source, message);
}
===================

it include two parts:

* first check whether the eventSource exists, if not, create it

** write message into the eventSource

Based on my experience, there is a typical permission issue that ASP.NET
worker process acount may not have permission to create EventSource, but
can write into an existing eventsource. Therefore, you can try checking
whether you can get this code work or if your original problem is due to
the eventsource is not correctly created.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>From: coconet <(E-Mail Removed)>
>Newsgroups: microsoft.public.dotnet.framework.aspnet
>Subject: Re: Logging Application Block Not Writing to Vista Event Log
>Date: Thu, 07 Feb 2008 10:24:05 -0500


>
>Please provide sample C# code or web.config text so I can test,
>thanks.
>
>
>On Thu, 07 Feb 2008 04:09:04 GMT, (E-Mail Removed) (Steven
>Cheng[MSFT]) wrote:
>
>>
>>Hi ,
>>
>>From your description, you're encountering some problem to use Logging
>>Application Block to write entry into eventlog on a Vista x64 box

,correct?
>>
>>Since you're developing an ASP.NET web applicaiton, are you using the VS
>>IDE's built-in test server or host the application in IIS? I suggest you
>>try the following things first:
>>
>>** change the listenter setting and also let EventLogListener to log all
>>the messages(not only high severity ones)
>>
>>** in your ASP.NET application, use normal .NET EventLog API to log into
>>the same EventSource to see whether it works.
>>
>>Sincerely,
>>
>>Steven Cheng
>>
>>Microsoft MSDN Online Support Lead
>>
>>
>>
>>This posting is provided "AS IS" with no warranties, and confers no

rights.
>>
>>
>>
>>
>>
>>--------------------
>>>From: coconet <(E-Mail Removed)>
>>>Newsgroups: microsoft.public.dotnet.framework.aspnet
>>>Subject: Logging Application Block Not Writing to Vista Event Log
>>>Date: Wed, 06 Feb 2008 13:59:17 -0500

>>
>>>
>>>
>>>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.Enterpris eLibrary.Logging.Configura

ti
>>on.FlatFileTraceListenerData,
>>>Microsoft.Practices.EnterpriseLibrary.Logging , Version=3.1.0.0,
>>>Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
>>> traceOutputOptions="None"
>>>type="Microsoft.Practices.EnterpriseLibrary.Log ging.TraceListeners.FlatFi

le
>>TraceListener,
>>>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.Enterpris eLibrary.Logging.Configura

ti
>>on.FormattedEventLogTraceListenerData,
>>>Microsoft.Practices.EnterpriseLibrary.Logging , Version=3.1.0.0,
>>>Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
>>> traceOutputOptions="None"
>>>
>>>type="Microsoft.Practices.EnterpriseLibrary.Log ging.TraceListeners.Format

te
>>dEventLogTraceListener,
>>>Microsoft.Practices.EnterpriseLibrary.Logging , Version=3.1.0.0,
>>>Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
>>> name="Formatted EventLog TraceListener"
>>>/>
>>></listeners>
>>><formatters>
>>><add
>>> template="Timestamp: {timestamp}&#xD;&#xA;Message:
>>>{message}&#xD;&#xA;Category: {category}&#xD;&#xA;Priority:
>>>{priority}&#xD;&#xA;EventId: {eventid}&#xD;&#xA;Severity:
>>>{severity}&#xD;&#xA;Title:{title}&#xD;&#xA;Mach ine:
>>>{machine}&#xD;&#xA;Application Domain: {appDomain}&#xD;&#xA;Process
>>>Id: {processId}&#xD;&#xA;Process Name: {processName}&#xD;&#xA;Win32
>>>Thread Id: {win32ThreadId}&#xD;&#xA;Thread Name:
>>>{threadName}&#xD;&#xA;Extended Properties: {dictionary({key} -
>>>{value}&#xD;&#xA}"
>>>
>>>type="Microsoft.Practices.EnterpriseLibrary.Log ging.Formatters.TextFormat

te
>>r,
>>>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 &amp; Warnings">
>>><listeners>
>>><add
>>> name="Formatted EventLog TraceListener"
>>>/>
>>></listeners>
>>></errors>
>>></specialSources>
>>></loggingConfiguration>
>>>
>>>
>>>
>>>
>>>

>
>


 
Reply With Quote
 
coconet
Guest
Posts: n/a
 
      02-11-2008

That does not show me how to do it with the Logging Application Block.
I know how to manually log with code. I need to see a simple web
application project's web.config file and .cs file showing how to
write errors-only to the application event log while writing all
information (debug/trace/error) to a local text file.

Please try again.

Thanks.


On Fri, 08 Feb 2008 06:52:07 GMT, (E-Mail Removed) (Steven
Cheng[MSFT]) wrote:

>Thanks for your reply Coconet,
>
>The code to manually write an EventLog entry is quite simple, here is a
>function doing it:
>
>========================
>private void btnWriteEventLog_Click(object sender, EventArgs e)
> {
> string source = "my App EventSource";
> string log = "Application";
> string message = "require more gas!";
>
> if (!EventLog.SourceExists(source))
> {
> EventLog.CreateEventSource(source, log);
> }
>
> EventLog.WriteEntry(source, message);
>}
>===================
>

 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      02-12-2008
Thanks for your reply,

The Enterprise Library Logging block code is also straightforward, my test
just used a single EventLog Listener and write a message into the test
event source. On Vista box, it execute under an application run with
Elevated privilege and it works well.


======code=======
private void button1_Click(object sender, EventArgs e)
{
LogEntry entry = new LogEntry();
entry.EventId = 1;
entry.Priority = 1;
entry.Message = "This is a test message.";
entry.Categories.Clear();
entry.Categories.Add("General");
Logger.Write(entry);
MessageBox.Show("Log is written");
}
=====================

=========config ==========
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="loggingConfiguration"
type="Microsoft.Practices.EnterpriseLibrary.Loggin g.Configuration.LoggingSet
tings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<section name="dataConfiguration"
type="Microsoft.Practices.EnterpriseLibrary.Data.C onfiguration.DatabaseSetti
ngs, Microsoft.Practices.EnterpriseLibrary.Data, Version=3.1.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</configSections>
<loggingConfiguration name="Logging Application Block"
tracingEnabled="true"
defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">
<listeners>
<add source="Enterprise Library Logging" formatter="Text
Formatter"
log="Application" machineName=""
listenerDataType="Microsoft.Practices.EnterpriseLi brary.Logging.Configuratio
n.FormattedEventLogTraceListenerData,
Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
traceOutputOptions="None"
type="Microsoft.Practices.EnterpriseLibrary.Loggin g.TraceListeners.Formatted
EventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging,
Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
name="Formatted EventLog TraceListener" />
</listeners>
<formatters>
<add template="Timestamp: {timestamp}&#xD;&#xA;Message:
{message}&#xD;&#xA;Category: {category}&#xD;&#xA;Priority:
{priority}&#xD;&#xA;EventId: {eventid}&#xD;&#xA;Severity:
{severity}&#xD;&#xA;Title:{title}&#xD;&#xA;Machine :
{machine}&#xD;&#xA;Application Domain: {appDomain}&#xD;&#xA;Process Id:
{processId}&#xD;&#xA;Process Name: {processName}&#xD;&#xA;Win32 Thread Id:
{win32ThreadId}&#xD;&#xA;Thread Name: {threadName}&#xD;&#xA;Extended
Properties: {dictionary({key} - {value}&#xD;&#xA}"

type="Microsoft.Practices.EnterpriseLibrary.Loggin g.Formatters.TextFormatter
, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
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 &amp; Warnings">
<listeners>
<add name="Formatted EventLog TraceListener" />
</listeners>
</errors>
</specialSources>
</loggingConfiguration>
</configuration>
===========================

Performing the same test and compare with your original case may help
verify whether the problem is specific to the application context(security,
application mode -- web or desktop ...).

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>From: coconet <(E-Mail Removed)>
>Newsgroups: microsoft.public.dotnet.framework.aspnet
>Subject: Re: Logging Application Block Not Writing to Vista Event Log
>Date: Mon, 11 Feb 2008 13:40:13 -0500


>Path:

TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSF TFEEDS02.phx.gbl!newsfeed0
0.sul.t-online.de!t-online.de!border2.nntp.dca.giganews.com!border1.nn tp.dca
.giganews.com!nntp.giganews.com!local02.nntp.dca.g iganews.com!news.giganews.
com.POSTED!not-for-mail
>Xref: TK2MSFTNGHUB02.phx.gbl microsoft.public.dotnet.framework.aspnet:58839
>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
>
>
>That does not show me how to do it with the Logging Application Block.
>I know how to manually log with code. I need to see a simple web
>application project's web.config file and .cs file showing how to
>write errors-only to the application event log while writing all
>information (debug/trace/error) to a local text file.
>
>Please try again.
>
>Thanks.
>
>
>On Fri, 08 Feb 2008 06:52:07 GMT, (E-Mail Removed) (Steven
>Cheng[MSFT]) wrote:
>
>>Thanks for your reply Coconet,
>>
>>The code to manually write an EventLog entry is quite simple, here is a
>>function doing it:
>>
>>========================
>>private void btnWriteEventLog_Click(object sender, EventArgs e)
>> {
>> string source = "my App EventSource";
>> string log = "Application";
>> string message = "require more gas!";
>>
>> if (!EventLog.SourceExists(source))
>> {
>> EventLog.CreateEventSource(source, log);
>> }
>>
>> EventLog.WriteEntry(source, message);
>>}
>>===================
>>

>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Logging exception with java.util.logging.Logger#log() to file only Royan Java 1 04-01-2008 09:42 PM
Writing to a registered source in the Application event log with I =?Utf-8?B?SmVmZkRvdE5ldA==?= ASP .Net 6 08-01-2006 09:19 PM
My.Log.Writeexception not writing to Application Event Log. =?Utf-8?B?VG9tIFdpbmdlcnQ=?= ASP .Net 0 01-20-2006 06:41 PM
My.Log.WriteException not writing to Event Log with ASP.Net 2.0 Tom Wingert ASP .Net Web Services 0 01-12-2006 06:46 PM
Include the application data with the tracer msg in Logging Application block Samy ASP .Net 0 11-09-2005 08:03 PM



Advertisments