473,480 Members | 1,922 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problems writing to the Event Log

Everyone,

I'm having trouble writing an event to the event log. Here is the
chunk of code I currently have.

-----------------------------------------------------------------------
Private Shared Function WriteErrorToLog(ByVal objError As
System.Text.StringBuilder, ByVal strSource As String) As Boolean
Dim objEL As New EventLog
Dim blnreturnvalue As Boolean

Dim Response As System.Web.HttpResponse
Response = System.Web.HttpContext.Current.Response

Try
If objEL.SourceExists(strSource) = False Then
objEL.CreateEventSource(strSource, "Application")
End If

objEL.Source = strSource
objEL.WriteEntry(objError.ToString(),
EventLogEntryType.Error)
blnreturnvalue = True
Catch ex As Exception
Response.Write("MSG: " & ex.Message & "<br>")
Response.Write("ST: " & ex.StackTrace & "<br>")
blnreturnvalue = False
End Try

Return blnreturnvalue
End Function
-----------------------------------------------------------------------

When I call this function I see the following error ...

MSG: Cannot open log for source {0}. You may not have write access.

I'm at a complete loss as to what's going on?? has writing to the
event log become such a chore now?? this is a little crazy ... I've
been at this for a day or so. I've tried switching the impersonate
setting (right now it's at false), permissions on the ASP.NET account,
the IUSR account etc ... I'm running out of ideas.

Thanks in advance for any assistance !

Scott Vercuski
sv*******@parker.com
Jul 21 '05 #1
2 4166
I had same trouble couple of days ago...

2. A better way is to leave the processModel’s username set to machine and create the required registry entry yourself. Open the Registry editor and access the following key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servic es\Eventlog\Application
Create a new key at this level by the user-def. name

Now within this key, add a new string value and set its name to EventMessageFile and set its value to: C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Event LogMessages.dll

See it -> Chapter 4
http://www.techcontent.com/TG70315FAQ.htm
"Scott Vercuski" wrote:
Everyone,

I'm having trouble writing an event to the event log. Here is the
chunk of code I currently have.

-----------------------------------------------------------------------
Private Shared Function WriteErrorToLog(ByVal objError As
System.Text.StringBuilder, ByVal strSource As String) As Boolean
Dim objEL As New EventLog
Dim blnreturnvalue As Boolean

Dim Response As System.Web.HttpResponse
Response = System.Web.HttpContext.Current.Response

Try
If objEL.SourceExists(strSource) = False Then
objEL.CreateEventSource(strSource, "Application")
End If

objEL.Source = strSource
objEL.WriteEntry(objError.ToString(),
EventLogEntryType.Error)
blnreturnvalue = True
Catch ex As Exception
Response.Write("MSG: " & ex.Message & "<br>")
Response.Write("ST: " & ex.StackTrace & "<br>")
blnreturnvalue = False
End Try

Return blnreturnvalue
End Function
-----------------------------------------------------------------------

When I call this function I see the following error ...

MSG: Cannot open log for source {0}. You may not have write access.

I'm at a complete loss as to what's going on?? has writing to the
event log become such a chore now?? this is a little crazy ... I've
been at this for a day or so. I've tried switching the impersonate
setting (right now it's at false), permissions on the ASP.NET account,
the IUSR account etc ... I'm running out of ideas.

Thanks in advance for any assistance !

Scott Vercuski
sv*******@parker.com

Jul 21 '05 #2
Lauri,

Thank you for your reply. I read the Chapter 4 code but
unfortuantely it won't help with my problem. The "source" I'm using
is coming directly from the exception in a try catch block ... EX:

Dim objEL As New EventLog

Try
<CODE>
Catch ex as Exception
If objEL.SourceExists(ex.Source) = False Then
objEL.CreateEventSource(ex.Source, "Application")
End If
objEL.Source = ex.Source
objEL.WriteEntry(ex.StackTrace,
EventLogEntryType.Error)
end try

I'm using this to create a generic exception handler so the source
could technically be coming from almost anywhere. I'd rather not try
and write a dynamic registry entry generator for every source I
encounter.

Thank you again !
Scott Vercuski
sv*******@parker.com

"Lauri" <La***@discussions.microsoft.com> wrote in message news:<27**********************************@microso ft.com>...
I had same trouble couple of days ago...

2. A better way is to leave the processModel’s username set to machine and create the required registry entry yourself. Open the Registry editor and access the following key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servic es\Eventlog\Application
Create a new key at this level by the user-def. name

Now within this key, add a new string value and set its name to EventMessageFile and set its value to: C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Event LogMessages.dll

See it -> Chapter 4
http://www.techcontent.com/TG70315FAQ.htm
"Scott Vercuski" wrote:
Everyone,

I'm having trouble writing an event to the event log. Here is the
chunk of code I currently have.

-----------------------------------------------------------------------
Private Shared Function WriteErrorToLog(ByVal objError As
System.Text.StringBuilder, ByVal strSource As String) As Boolean
Dim objEL As New EventLog
Dim blnreturnvalue As Boolean

Dim Response As System.Web.HttpResponse
Response = System.Web.HttpContext.Current.Response

Try
If objEL.SourceExists(strSource) = False Then
objEL.CreateEventSource(strSource, "Application")
End If

objEL.Source = strSource
objEL.WriteEntry(objError.ToString(),
EventLogEntryType.Error)
blnreturnvalue = True
Catch ex As Exception
Response.Write("MSG: " & ex.Message & "<br>")
Response.Write("ST: " & ex.StackTrace & "<br>")
blnreturnvalue = False
End Try

Return blnreturnvalue
End Function
-----------------------------------------------------------------------

When I call this function I see the following error ...

MSG: Cannot open log for source {0}. You may not have write access.

I'm at a complete loss as to what's going on?? has writing to the
event log become such a chore now?? this is a little crazy ... I've
been at this for a day or so. I've tried switching the impersonate
setting (right now it's at false), permissions on the ASP.NET account,
the IUSR account etc ... I'm running out of ideas.

Thanks in advance for any assistance !

Scott Vercuski
sv*******@parker.com

Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3228
by: Craig Hurcum | last post by:
Hi, I'm trying to log a formatted event to the Windows NT Security Event Log but I am having problems. I can get events into the log, but always unformatted with the data appearing in the...
2
17397
by: jfixsen | last post by:
Hello! Oracle 9.2.0.4 SunOS pchi-db01 5.8 Generic_108528-19 sun4u sparc SUNW,Ultra-EnterpriseSystem = SunOS Node = pchi-db01 Release = 5.8 KernelID = Generic_108528-19 Machine = sun4u...
8
12506
by: Colin Cashman | last post by:
In a program I'm writing, I have a class that generates a certain event. However, there may be dozens or even hundreds of instances of this particular class, which makes adding and removing...
2
2562
by: Suzanne | last post by:
Hi all, I'm reposting this message as I'm experiencing this problem more and more frequently : I really hope someone out there can help me as I've been tearing my hair out on this one for a...
6
10201
by: Don | last post by:
I'm having problems working with a streamwriter object. After closing the streamwriter and setting it to Nothing, I try to delete the file it was writing to, but I always get the following error...
2
241
by: Scott Vercuski | last post by:
Everyone, I'm having trouble writing an event to the event log. Here is the chunk of code I currently have. ----------------------------------------------------------------------- Private...
0
1476
by: myoungbl | last post by:
Note:I'm using VB.NET, .NET 2.0, to write a service application. So far I've only attempted to run it on the development machine. I'm have a couple of problems I can't quite figure out with a...
5
3507
by: JasonX | last post by:
Im having problems with my program, in that if I close the main form while my new thread is doing work which involves writing to the main form, then I get an error about a disposed object. To...
10
1826
by: jodleren | last post by:
Hi I know, that there are a lot of people having problems with orkut.com, errors like "object expected" and named objects missing. When loading the site can generate some 10 errors, and still...
0
7037
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7032
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7076
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6730
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5321
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4767
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4471
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2976
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1294
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.