Re: Write to IIS/Event Log File ?

From: UAError (null_at_null.null)
Date: 11/12/04


Date: Fri, 12 Nov 2004 08:14:55 -0500


"Angelos Karantzalis" <akarantzalis@yahoo.com> wrote:

>Hi y'all,
>
> recently I've come across a situation where a web service needs to deal
>with an exception that might arise, originating from a COM+ component. It
>then returns an int value (please don't ask me why) indicating that there
>was something wrong with the requested operation.
>
>Assuming that I don't really know all the posible exceptions that might
>arise from the COM+ layer, and therefore I can't accurately return an int
>identifying the exception, I need a way to log the actual exception trace,
>either in the web service, or in the COM+ layer.
>
>Writting to the event log threw me Security Exceptions, because ASPNET
>doesn't have write access to the event log.

ASP.NET should have rights to WRITE to the application event
log - however it does not have right to create a new Event
Source:

PRB: "Requested Registry Access Is Not Allowed" Error
Message When ASP.NET Application Tries to Write New
EventSource in the EventLog
http://support.microsoft.com/default.aspx?scid=kb;en-us;329291

Little examples like

How To Write to an Event Log by Using Visual C# .NET
http://support.microsoft.com/default.aspx?scid=kb;en-us;307024

fail to mention this fact.

For a more thorough treatment of event logging see

Visual Basic and Visual C# Concepts: Walkthrough: Installing
an Event Log Component
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbwlkwalkthroughcreatingeventloginstallers.asp

In essence it is your project's installer's responsibilty to
create the event source when the application/component is
installed - and it should also delete it when the
application/component is removed.

>Since the COM+ level runs under
>the same identity apparently, I can't do it there either ..
>
Well you can fix that. If the Enterprise Component specifies

[assembly: ApplicationActivation(ActivationOption.Library)]

then you have no choice and will be running in the caller's
security context. If you specify

[assembly: ApplicationActivation(ActivationOption.Server)]

then you can configure a dedicated account for the Server
through Component Services Properties ("Identity" Tab) -
this in fact is the tactic to use to perform actions that
requires elevated privileges that ASP.NET has no business
having. Note that the Server must reside in the GAC.

.NET Framework Developer's Guide: Registering Serviced
Components
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconregisteringservicedcomponents.asp

NET Framework Class Library: ApplicationActivationAttribute
Class
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystementerpriseservicesapplicationactivationattributeclasstopic.asp

.NET Framework Class Library: ActivationOption Enumeration
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystementerpriseservicesactivationoptionclasstopic.asp

>So, question: how can I log either into the IIS Log, or the Event log from a
>web service ?
>
>Cheers,
>Angel
>O:]
>



Relevant Pages

  • Write to IIS/Event Log File ?
    ... with an exception that might arise, ... either in the web service, or in the COM+ layer. ... Writting to the event log threw me Security Exceptions, ...
    (microsoft.public.dotnet.general)
  • Re: Event Log Trust Level?
    ... What I do in this case is install the event log as part of an installer ... package and then just use write to the event log from the app. ... > but it comes back with this exception: ... > source, String logName, String machineName, Boolean ...
    (microsoft.public.dotnet.security)
  • Re: Problem with Exception Handling using Web Services
    ... private void checkPassword ... The Exception is definitely thrown, but when I run it in a web browser it ... >> Microsoft Visual C#.NET to interact with the web service. ... >> Adrian Burka ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: Problem referencing web service
    ... > It is my web service and it works fine on my local server. ... Given that this is a web service, you'd probably want to write the error to ... You would want to create an event log ... That will run the event log installer to install the event source, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Retry on certain exceptions?
    ... because of a sql exception, I'll end up getting a bunch of suspended ... custom exception I'll end up with 1 suspended message. ... would be no suspended messages if the web service throws my custom exception ... then add a loop shape. ...
    (microsoft.public.biztalk.general)