Logging to event log

Logging to event log

Post by Colin Youn » Sat, 26 Jan 2002 01:47:14



I'm trying to use the Exception Management Application Block from Microsoft.
I am encountering exceptions that say "Requested registry access is not
allowed". I think this error is because I need permission to create the new
event category. The solution I've found (in the aspnet_account_readme.doc
file) is to create the required category and then ASP.NET will be able to
log those events just fine. I'm assuming that I'll be able to find the
category by going through the source code, but how do I create the category,
short of writing a custom .NET program just to create the category?

Thanks

Colin

 
 
 

Logging to event log

Post by Quentin Hu » Sat, 26 Jan 2002 05:53:03


Colin Young

Hi Colin. I would like to help you with your issue.  First please read this
article which describes in depth how to do what I think you want.  After
this, please describe in a bit more depth how what you are doing differs
from the article --if it doesn't help.  Either way please let me know if I
was able to help you or if you need anything else!

http://support.microsoft.com/support/kb/articles/q306/3/55.asp

Thanks

Quentin Hurd
Microsoft ASP.NET Developer Support

[ This posting is provided "AS IS" with no warranties, and confers no
rights. You assume all risk for your use. ? 2001 Microsoft Corporation. All
rights reserved. ]

 
 
 

Logging to event log

Post by Colin Youn » Wed, 30 Jan 2002 06:53:31


I'm trying to write unhandled exceptions to the application event log using
the Application Block provided on the MS website. The code uses a custom
source which needs to be entered into the registry before I will be able to
log entries with that source in the event log. I already have custom error
handling working on my website, I just need a way to write the exceptions
that can't be handled automatically into the event log.

Thanks

Colin


Quote:> Colin Young

> Hi Colin. I would like to help you with your issue.  First please read
this
> article which describes in depth how to do what I think you want.  After
> this, please describe in a bit more depth how what you are doing differs
> from the article --if it doesn't help.  Either way please let me know if I
> was able to help you or if you need anything else!

> http://support.microsoft.com/support/kb/articles/q306/3/55.asp

> Thanks

> Quentin Hurd
> Microsoft ASP.NET Developer Support

> [ This posting is provided "AS IS" with no warranties, and confers no
> rights. You assume all risk for your use. ? 2001 Microsoft Corporation.
All
> rights reserved. ]

 
 
 

Logging to event log

Post by Quentin Hu » Wed, 30 Jan 2002 07:11:11


Hi Colin,

Perhaps I'm unsure of what you are trying to accomplish, but if you look at
the KB article I previously provided
there is methodology described that shows you how to process unhandeled
exceptions.  I've copied a bit of the article.  Is this the kind of
information you are looking for?

"How to Use the Application_Error Event
Similar to the Page_Error event, you can use the Application_Error event to
trap errors that occur in your application. Due to the event's
application-wide scope, you can log of application error information or
handle other application-level errors that may occur...."

Again this article can be found at
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q306355

Thanks,

Quentin Hurd

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. ? 2001 Microsoft Corporation. All rights
reserved.

 
 
 

Logging to event log

Post by Colin Youn » Wed, 30 Jan 2002 23:35:44


I have read that article and I am already handling errors in the
Application_Error event and I am using a custom error page to display the
results to the user. The problem is that there is code something like this:

if (!System.Diagnostics.EventLog.SourceExists("MyCustomErrorType"))
    System.Diagnostics.EventLog.CreateEventSource("MyCustomErrorType",
"Application");
System.Diagnostics.EventLog ev = new System.Diagnostics.EventLog();
ev.Source = "MyCustomErrorType";
ev.Wri*try(e.Message.ToString() + "\nFormat: " + format.ToString());

I don't have the proper permissions in ASP to run the CreateEventSource
method. Short of writing a program that I run as administrator, what
permissions do I need to set to allow the ASP.NET process to execute that
function? I've already tried running as system, and that doesn't do it.

Colin


Quote:> Hi Colin,

> Perhaps I'm unsure of what you are trying to accomplish, but if you look
at
> the KB article I previously provided
> there is methodology described that shows you how to process unhandeled
> exceptions.  I've copied a bit of the article.  Is this the kind of
> information you are looking for?

> "How to Use the Application_Error Event
> Similar to the Page_Error event, you can use the Application_Error event
to
> trap errors that occur in your application. Due to the event's
> application-wide scope, you can log of application error information or
> handle other application-level errors that may occur...."

> Again this article can be found at
> http://www.veryComputer.com/;EN-US;q306355

> Thanks,

> Quentin Hurd

> This posting is provided "AS IS" with no warranties, and confers no
rights.
> You assume all risk for your use. ? 2001 Microsoft Corporation. All rights
> reserved.

 
 
 

Logging to event log

Post by Quentin Hurd ( » Thu, 31 Jan 2002 03:41:23


Hi,

The following information is from a "yet to be published" article...

"Using the Event Log:

Applications that need to write to the Application event log can do so while
running as the ASPNET account. If an application needs to create a new
event log
category, it must create a registry key under the HKLM hive, which the
ASPNET
account cannot do. If impersonation is enabled and a privileged account is
impersonated, the category can be created at run time. Otherwise, an
administrator can create the category and the application can write to it
at run
time.

Applications that need to create new event log categories should create the
categories at installation. Once the category is created, the ASPNET
account can
write to the log."

If you need more information about this please let me know...

Thanks,

Quentin Hurd

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. ? 2001 Microsoft Corporation. All rights
reserved.

 
 
 

Logging to event log

Post by Colin Youn » Thu, 31 Jan 2002 06:34:04


That sounds an awful lot like an article that is available on
www.gotdotnet.com. The problem is I don't know exactly what key I need to
create in the registry, and the article doesn't have any more information
about how to go about creating the key at installation. Do I need to go to
the trouble of writing a program to run during installation that does
nothing but create the category, or is there some documentation about what I
need to put in the key so I can do it directly with a .reg file or
something?

Thanks

Colin



Quote:> Hi,

> The following information is from a "yet to be published" article...

> "Using the Event Log:

> Applications that need to write to the Application event log can do so
while
> running as the ASPNET account. If an application needs to create a new
> event log
> category, it must create a registry key under the HKLM hive, which the
> ASPNET
> account cannot do. If impersonation is enabled and a privileged account is
> impersonated, the category can be created at run time. Otherwise, an
> administrator can create the category and the application can write to it
> at run
> time.

> Applications that need to create new event log categories should create
the
> categories at installation. Once the category is created, the ASPNET
> account can
> write to the log."

> If you need more information about this please let me know...

> Thanks,

> Quentin Hurd

> This posting is provided "AS IS" with no warranties, and confers no
rights.
> You assume all risk for your use. ? 2001 Microsoft Corporation. All rights
> reserved.

 
 
 

Logging to event log

Post by Andreas K. Pal » Thu, 31 Jan 2002 17:02:06


Hi there,

I do have the same problem, just brought over code I developed in
beta2 to RTM and now I have this security exception, I think MS
changed the concept here a bit ?!

regards
andreas



>That sounds an awful lot like an article that is available on
>www.gotdotnet.com. The problem is I don't know exactly what key I need to
>create in the registry, and the article doesn't have any more information
>about how to go about creating the key at installation. Do I need to go to
>the trouble of writing a program to run during installation that does
>nothing but create the category, or is there some documentation about what I
>need to put in the key so I can do it directly with a .reg file or
>something?

>Thanks

>Colin



>> Hi,

>> The following information is from a "yet to be published" article...

>> "Using the Event Log:

>> Applications that need to write to the Application event log can do so
>while
>> running as the ASPNET account. If an application needs to create a new
>> event log
>> category, it must create a registry key under the HKLM hive, which the
>> ASPNET
>> account cannot do. If impersonation is enabled and a privileged account is
>> impersonated, the category can be created at run time. Otherwise, an
>> administrator can create the category and the application can write to it
>> at run
>> time.

>> Applications that need to create new event log categories should create
>the
>> categories at installation. Once the category is created, the ASPNET
>> account can
>> write to the log."

>> If you need more information about this please let me know...

>> Thanks,

>> Quentin Hurd

>> This posting is provided "AS IS" with no warranties, and confers no
>rights.
>> You assume all risk for your use. ? 2001 Microsoft Corporation. All rights
>> reserved.

 
 
 

Logging to event log

Post by Andreas K. Pal » Thu, 31 Jan 2002 19:02:07


Once again me, I could trace down my problem to some new
features within web.config (at least they didn't bother me in beta2).

There is a new entry in web.config

<configuration>
   <system.web>
      <securityPolicy>
         <trustLevel>

have a look if this might fix your problem

also have a look at this:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnne...

best regards
andreas

On Wed, 30 Jan 2002 09:02:06 +0100, Andreas K. Palm


>Hi there,

>I do have the same problem, just brought over code I developed in
>beta2 to RTM and now I have this security exception, I think MS
>changed the concept here a bit ?!

>regards
>andreas



>>That sounds an awful lot like an article that is available on
>>www.gotdotnet.com. The problem is I don't know exactly what key I need to
>>create in the registry, and the article doesn't have any more information
>>about how to go about creating the key at installation. Do I need to go to
>>the trouble of writing a program to run during installation that does
>>nothing but create the category, or is there some documentation about what I
>>need to put in the key so I can do it directly with a .reg file or
>>something?

>>Thanks

>>Colin



>>> Hi,

>>> The following information is from a "yet to be published" article...

>>> "Using the Event Log:

>>> Applications that need to write to the Application event log can do so
>>while
>>> running as the ASPNET account. If an application needs to create a new
>>> event log
>>> category, it must create a registry key under the HKLM hive, which the
>>> ASPNET
>>> account cannot do. If impersonation is enabled and a privileged account is
>>> impersonated, the category can be created at run time. Otherwise, an
>>> administrator can create the category and the application can write to it
>>> at run
>>> time.

>>> Applications that need to create new event log categories should create
>>the
>>> categories at installation. Once the category is created, the ASPNET
>>> account can
>>> write to the log."

>>> If you need more information about this please let me know...

>>> Thanks,

>>> Quentin Hurd

>>> This posting is provided "AS IS" with no warranties, and confers no
>>rights.
>>> You assume all risk for your use. ? 2001 Microsoft Corporation. All rights
>>> reserved.

 
 
 

1. Error logging to event log

Hello, I am getting an error when trying to log a message
to the event log in my asp app.  The app and log are on
the same computer.

I have a class that my aspx page uses, and that class logs
errors to the event log.  When in a console application it
all works fine.  I am getting some kind of security
exception.

Code:

//write entry
ev.WriteEntry(System.DateTime.Now + " | " + logName + "
| " + connString + " | " + message,
EventLogEntryType.Error);

Throws:
System.Security.SecurityException

Message: Requested registry access is not allowed.

Anyone experience this before?

2. Seagate Backup Exec Tape Management Question

3. Logging events on information log

4. CALLING IOCTLS FROM A NON-FILTER-DRIVER

5. error log in application event log

6. Schwab Sync Problems

7. Log Application Error to Event Log

8. 8.6.9 sendmail-via-inetd 'authentic hostname' problem

9. Reading Log from Transaction Log Backup

10. automatically log-out users that are logged-in

11. Page caching - how to still log page access in server log

12. Rights needed to create an event in event log?

13. Can't write to event log - Event ID 1085 EFS recovery failed