473,398 Members | 2,088 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

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 4161
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
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
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
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
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
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
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
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
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
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.