Write to event log

G

Guest

I am trying to write to the event log with the My.Log.WriteEntry("MyMessage")

The call does nothing. I think that I need to set up the Listeners in the
config file. Is there any information on how to set up the listener for the
Application log and how to setup new logs for the app.

Thank you,
 
W

Walter Wang [MSFT]

Hi Jerry,

What you needed is following MSDN article on this:

#How to: Write to an Application Event Log
http://msdn2.microsoft.com/en-us/library/07347hdt.aspx

I hope this helps. Please feel free to post here if anything is unclear.

Sincerely,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

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

Guest

Thank you for the reply.

I now get a error in the application event log.

The description for Event ID ( 0 ) in Source ( ContentDepot ) cannot be
found. The local computer may not have the necessary registry information or
message DLL files to display messages from a remote computer. You may be able
to use the /AUXSOURCE= flag to retrieve this description; see Help and
Support for details. The following information is part of the event: Test
Information Message.

I have asked this question before and did not understand the answers. This
is a plain install of windows server 2003 using Visual Studio 2005 and visual
basic for the development environment . The application is a asp.net
application running on IIS 6.0

The entries in the web.config are:

<system.diagnostics>

<sources>
<!-- This section defines the logging configuration for
My.Application.Log -->
<source name="DefaultSource" switchName="DefaultSwitch">
<listeners>
<add name="EventLog"/>
</listeners>
</source>
</sources>
<switches>
<add name="DefaultSwitch" value="Information" />
</switches>
<sharedListeners>
<add name="EventLog"
type="System.Diagnostics.EventLogTraceListener, System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"
initializeData="DDapp"/>
</sharedListeners>
</system.diagnostics>
 
W

Walter Wang [MSFT]

Hi Jerry,

Thank you for your quick update.

I've reviewed your past post dated Aug. 11 about "Error Writing to Event
Log". In that post, your question is about writing event log from ASP.NET
web application.

I understand that you currently have created the event source in registry
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application\DD
app which is required because by default the service account NETWORK
SERVICE running ASP.NET will not have the privilege to create it
automatically.

However, you need another registry value ErrorMessageFile to fix the issue
you're seeing:

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application\D
Dapp]
"EventMessageFile"="c:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\Event
LogMessages.dll"

Change the path accordingly.

This is required by the Event Log system.

I hope this helps. Please feel free to post here if anything is unclear.

By the way, for ASP.NET related questions, I recommend you post in the
newsgroup microsoft.public.dotnet.framework.aspnet. Thank you.


Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

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

Walter Wang [MSFT]

Hi Jerry,

Have you tried my suggestion in my last post? Does it work for you? Please
post here if anything is unclear.

Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top