473,804 Members | 2,455 Online
Bytes | Software Development & Data Engineering Community
+ 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.Str ingBuilder, ByVal strSource As String) As Boolean
Dim objEL As New EventLog
Dim blnreturnvalue As Boolean

Dim Response As System.Web.Http Response
Response = System.Web.Http Context.Current .Response

Try
If objEL.SourceExi sts(strSource) = False Then
objEL.CreateEve ntSource(strSou rce, "Applicatio n")
End If

objEL.Source = strSource
objEL.WriteEntr y(objError.ToSt ring(),
EventLogEntryTy pe.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*******@parke r.com
Jul 21 '05 #1
2 4197
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_MACH INE\SYSTEM\Curr entControlSet\S ervices\Eventlo g\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 EventMessageFil e and set its value to: C:\WINDOWS\Micr osoft.NET\Frame work\v1.1.4322\ EventLogMessage s.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.Str ingBuilder, ByVal strSource As String) As Boolean
Dim objEL As New EventLog
Dim blnreturnvalue As Boolean

Dim Response As System.Web.Http Response
Response = System.Web.Http Context.Current .Response

Try
If objEL.SourceExi sts(strSource) = False Then
objEL.CreateEve ntSource(strSou rce, "Applicatio n")
End If

objEL.Source = strSource
objEL.WriteEntr y(objError.ToSt ring(),
EventLogEntryTy pe.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*******@parke r.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.SourceExi sts(ex.Source) = False Then
objEL.CreateEve ntSource(ex.Sou rce, "Applicatio n")
End If
objEL.Source = ex.Source
objEL.WriteEntr y(ex.StackTrace ,
EventLogEntryTy pe.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*******@parke r.com

"Lauri" <La***@discussi ons.microsoft.c om> wrote in message news:<27******* *************** ************@mi crosoft.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_MACH INE\SYSTEM\Curr entControlSet\S ervices\Eventlo g\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 EventMessageFil e and set its value to: C:\WINDOWS\Micr osoft.NET\Frame work\v1.1.4322\ EventLogMessage s.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.Str ingBuilder, ByVal strSource As String) As Boolean
Dim objEL As New EventLog
Dim blnreturnvalue As Boolean

Dim Response As System.Web.Http Response
Response = System.Web.Http Context.Current .Response

Try
If objEL.SourceExi sts(strSource) = False Then
objEL.CreateEve ntSource(strSou rce, "Applicatio n")
End If

objEL.Source = strSource
objEL.WriteEntr y(objError.ToSt ring(),
EventLogEntryTy pe.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*******@parke r.com

Jul 21 '05 #3

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

Similar topics

1
3244
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 "Data" box and not the "Description" box - not very user friendly!! I have no trouble at all in writing to the Windows NT Application Log.
2
17420
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 BusType = <unknown>
8
12526
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 handlers to each instance a pain. Rather than go down that route, I was thinking of making the event static, so I would only need to add my handlers once, to the static event, which I can then trigger from inside my class. That leaves me with two...
2
2598
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 good while and I'm getting really frustrated now! My problem is this - my custom controls periodically disappear from my
6
10220
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 message: "The process cannot access the file "whatever" because it is being used by another process." I've even tried opening another file using the same streamwriter object before deleting the original file, but it's no use. Something keeps...
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 Shared Function WriteErrorToLog(ByVal objError As System.Text.StringBuilder, ByVal strSource As String) As Boolean Dim objEL As New EventLog Dim blnreturnvalue As Boolean
0
1498
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 windows service I'm writing. The purpose of the service is to backup my Source Safe folders each night over to a machine that gets backed up each night. The 2 main problems I'm having are as follows: 1) If I set the Installer to install the service in...
5
3519
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 fix this, i have added an event, with the aim the main form subscribes to the event when it is created and unsubscribes as soon as its closed. This approach however has not fixed the problem. When the event is raised, it writes to the form using a...
10
1858
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 just leave a blue page - seems like it heavily rely on JS. Still, me and friends having problems and orkut seems just to ignore it. I am sure, that other poeple have problems, and I really wonder what
0
10561
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10318
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10302
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9132
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7608
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6845
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5505
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2976
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.