write to event log

From: July (qzheng@stewart.com)
Date: 10/25/02


From: "July" <qzheng@stewart.com>
Date: Fri, 25 Oct 2002 14:04:39 -0700


Hi, I was trying to add and write an event log to my
server event viewer in a vb.net web application. The code
I used below works fine in my vb.net window application
and it wrote to newlog1. But when using for the web
application, it gave me the following error:
-------------------
Security Exception
Description: The application attempted to perform an
operation not allowed by the security policy. To grant
this application the required permission please contact
your system administrator or change the application's
trust level in the configuration file.

Exception Details: System.Security.SecurityException:
Requested registry access is not allowed.
------------------------------

The code I'm using is as following:

------------------------
Imports System.Diagnostics
Dim EventLog1 As System.Diagnostics.EventLog

If Not EventLog.SourceExists("Source1") Then
        EventLog.CreateEventSource("Source1", "NewLog1")
Else
        EventLog.DeleteEventSource("Source1")
        EventLog.CreateEventSource("Source1", "Newlog1")
End If

EventLog1.Source = "Source1"
EventLog1.WriteEntry("this is an informational message for
web service")
EventLog1.WriteEntry("this is an error message for web
service", Diagnostics.EventLogEntryType.Error)
----------------------------

Anyone has any detail idea about the error message? What
should I do about it?