Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > writing to Application event log

Reply
Thread Tools

writing to Application event log

 
 
John S
Guest
Posts: n/a
 
      08-27-2008
I have written a web service in VB.Net 3. I want to record any exceptions
generated in the Application event log.

For a Windows app, you can use the My.Application.Log.WriteException(ex) and
uncomment a couple of lines in the app.config file.

I can't work out how to do it in a webservice.

Can anyone help?
 
Reply With Quote
 
 
 
 
Mark Stevens
Guest
Posts: n/a
 
      08-27-2008
Try integrating the following:

using System.Diagnostics;

EventLog applicationEventLog = new EventLog("Application", ".",
"KeyName");

applicationEventLog.WriteEntry("Message...", EventLogEntryType.Error);

You will of course need to register the "KeyName" in the registry on
the server(s) using this code.

Hope this help,
Mark


On Wed, 27 Aug 2008 06:48:01 -0700, John S <(E-Mail Removed)>
wrote:

>I have written a web service in VB.Net 3. I want to record any exceptions
>generated in the Application event log.
>
>For a Windows app, you can use the My.Application.Log.WriteException(ex) and
>uncomment a couple of lines in the app.config file.
>
>I can't work out how to do it in a webservice.
>
>Can anyone help?

--
|\ _,,,---,,_ A picture used to be worth a
ZZZzzz /,`.-'`' -. ;-;;, thousand words - then along
|,4- ) )-,_. ,\ ( `'-' came television!
'---''(_/--' `-'\_)

Mark Stevens (mark at thepcsite fullstop co fullstop uk)

This message is provided "as is".
 
Reply With Quote
 
 
 
 
Mark Stevens
Guest
Posts: n/a
 
      08-27-2008
Missed a word out, last sentence should read:

You will of course need to register the "KeyName" in the registry on
the server(s) BEFORE using this code.

And "Keyname" is the source for the error.

Regards,
Mark

On Wed, 27 Aug 2008 16:23:14 +0100, Mark Stevens <(E-Mail Removed)>
wrote:

>Try integrating the following:
>
>using System.Diagnostics;
>
>EventLog applicationEventLog = new EventLog("Application", ".",
>"KeyName");
>
>applicationEventLog.WriteEntry("Message...", EventLogEntryType.Error);
>
>You will of course need to register the "KeyName" in the registry on
>the server(s) using this code.
>
>Hope this help,
>Mark
>
>
>On Wed, 27 Aug 2008 06:48:01 -0700, John S <(E-Mail Removed)>
>wrote:
>
>>I have written a web service in VB.Net 3. I want to record any exceptions
>>generated in the Application event log.
>>
>>For a Windows app, you can use the My.Application.Log.WriteException(ex) and
>>uncomment a couple of lines in the app.config file.
>>
>>I can't work out how to do it in a webservice.
>>
>>Can anyone help?

--
|\ _,,,---,,_ A picture used to be worth a
ZZZzzz /,`.-'`' -. ;-;;, thousand words - then along
|,4- ) )-,_. ,\ ( `'-' came television!
'---''(_/--' `-'\_)

Mark Stevens (mark at thepcsite fullstop co fullstop uk)

This message is provided "as is".
 
Reply With Quote
 
Steven Cheng [MSFT]
Guest
Posts: n/a
 
      08-28-2008
Hi John,

As Mark has suggested, you can use the Tracing and Diagnostics feature of
..NET framework /ASP.NET to perform logging. And it is provider based and
also quite flexible to configure via web.config file. Here are some web
articles introducing this:

#Diagnostics and Logging In ASP.NET
http://www.odetocode.com/Articles/294.aspx

#A Provider-Based Service for ASP.NET Tracing
http://msdn.microsoft.com/en-us/magazine/cc163596.aspx

#Logging JavaScript Errors To ASP.NET
http://james.newtonking.com/archive/2006/05/02/98.aspx


Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
http://www.velocityreviews.com/forums/(E-Mail Removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

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://support.microsoft.com/select/...tance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.



--------------------
>From: =?Utf-8?B?Sm9obiBT?= <(E-Mail Removed)>
>Subject: writing to Application event log
>Date: Wed, 27 Aug 2008 06:48:01 -0700


>I have written a web service in VB.Net 3. I want to record any exceptions
>generated in the Application event log.
>
>For a Windows app, you can use the My.Application.Log.WriteException(ex)

and
>uncomment a couple of lines in the app.config file.
>
>I can't work out how to do it in a webservice.
>
>Can anyone help?
>


 
Reply With Quote
 
John S
Guest
Posts: n/a
 
      08-28-2008
Hi,

Thanks for the help. I wanted to keep the process as close to the way we do
things in Windows Form applications, i.e. still using the
my.application.log.writeexception syntax.

With the information from your posts to start me off, I managed to do the
following:

1.Create a registry Key named after the Webservice name in the
eventlog hierachy.

2. Copy the <system.diagnostics> element from an app.config file,
created by VB for a Windoes App, into the web.config file in the
<configuration> element.

3. Follow the remarks in that section to uncomment a couple of lines
and to change the initializeData attribute to the same name as the new
registry key.

4. Build and Publish the project.

This now seems to work the way I want.

One strange thing occured. I forgot to create the registry key on one
occasion while testing. Instead of causing some sort of untrapped error as I
expected, it appeared to use the key belonging to an existing Web service
that I had already created with a totally different name! Can't explain how,
but provided everything is done properly I have my answer.

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

As for the "creating the registry entry", yes, you'd better always
precreate it before running the application because create registry entry
require higher permision than writting into it. There is a typical issue
that the developer forget to precreate the registry entry and cause the
application report "Access denied" error at runtime when running the
ASP.NET under a restricted account( the common case).

Sincerely,

Steven Cheng
Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(E-Mail Removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subs...#notifications.

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

--------------------
>From: =?Utf-8?B?Sm9obiBT?= <(E-Mail Removed)>
>References: <(E-Mail Removed)>

<(E-Mail Removed)>
>Subject: RE: writing to Application event log
>Date: Thu, 28 Aug 2008 02:20:00 -0700


> Hi,
>
>Thanks for the help. I wanted to keep the process as close to the way we

do
>things in Windows Form applications, i.e. still using the
>my.application.log.writeexception syntax.
>
>With the information from your posts to start me off, I managed to do the
>following:
>
> 1.Create a registry Key named after the Webservice name in the
>eventlog hierachy.
>
> 2. Copy the <system.diagnostics> element from an app.config file,
>created by VB for a Windoes App, into the web.config file in the
><configuration> element.
>
> 3. Follow the remarks in that section to uncomment a couple of lines
>and to change the initializeData attribute to the same name as the new
>registry key.
>
> 4. Build and Publish the project.
>
>This now seems to work the way I want.
>
>One strange thing occured. I forgot to create the registry key on one
>occasion while testing. Instead of causing some sort of untrapped error as

I
>expected, it appeared to use the key belonging to an existing Web service
>that I had already created with a totally different name! Can't explain

how,
>but provided everything is done properly I have my answer.
>
>


 
Reply With Quote
 
Steven Cheng [MSFT]
Guest
Posts: n/a
 
      09-02-2008
Hi John,

Do you still have any question on this?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(E-Mail Removed).


--------------------
>From: (E-Mail Removed) (Steven Cheng [MSFT])
>Organization: Microsoft
>Date: Fri, 29 Aug 2008 06:42:28 GMT
>Subject: RE: writing to Application event log


>
>Thanks for your reply John,
>
>As for the "creating the registry entry", yes, you'd better always
>precreate it before running the application because create registry entry
>require higher permision than writting into it. There is a typical issue
>that the developer forget to precreate the registry entry and cause the
>application report "Access denied" error at runtime when running the
>ASP.NET under a restricted account( the common case).
>
>Sincerely,
>
>Steven Cheng
>Microsoft MSDN Online Support Lead
>
>
>Delighting our customers is our #1 priority. We welcome your comments and
>suggestions about how we can improve the support we provide to you. Please
>feel free to let my manager know what you think of the level of service
>provided. You can send feedback directly to my manager at:
>(E-Mail Removed).
>
>================================================= =
>Get notification to my posts through email? Please refer to
>http://msdn.microsoft.com/en-us/subs...#notifications.
>
>================================================= =
>This posting is provided "AS IS" with no warranties, and confers no rights.
>
>--------------------
>>From: =?Utf-8?B?Sm9obiBT?= <(E-Mail Removed)>
>>References: <(E-Mail Removed)>

><(E-Mail Removed)>
>>Subject: RE: writing to Application event log
>>Date: Thu, 28 Aug 2008 02:20:00 -0700

>
>> Hi,
>>
>>Thanks for the help. I wanted to keep the process as close to the way we

>do
>>things in Windows Form applications, i.e. still using the
>>my.application.log.writeexception syntax.
>>
>>With the information from your posts to start me off, I managed to do the
>>following:
>>
>> 1.Create a registry Key named after the Webservice name in the
>>eventlog hierachy.
>>
>> 2. Copy the <system.diagnostics> element from an app.config file,
>>created by VB for a Windoes App, into the web.config file in the
>><configuration> element.
>>
>> 3. Follow the remarks in that section to uncomment a couple of lines
>>and to change the initializeData attribute to the same name as the new
>>registry key.
>>
>> 4. Build and Publish the project.
>>
>>This now seems to work the way I want.
>>
>>One strange thing occured. I forgot to create the registry key on one
>>occasion while testing. Instead of causing some sort of untrapped error

as
>I
>>expected, it appeared to use the key belonging to an existing Web service
>>that I had already created with a totally different name! Can't explain

>how,
>>but provided everything is done properly I have my answer.
>>
>>

>
>


 
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 Application Block Not Writing to Vista Event Log coconet ASP .Net 5 02-12-2008 04:42 AM
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
Need help on the Permissions needed to log to Event Log from ASP.NET? Henrik_the_boss ASP .Net 0 11-05-2003 10:14 AM



Advertisments