473,775 Members | 2,592 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Question about EventLog

I have a service with the following startup code...
Protected Overrides Sub OnStart(ByVal args() As String)
If Not Diagnostics.Eve ntLog.SourceExi sts("MyService" ) Then
Diagnostics.Eve ntLog.CreateEve ntSource("MySer vice", "MyServiceL og")
End If

Dim _eventLog As New Diagnostics.Eve ntLog
_eventLog.Sourc e = "MyService"
_eventLog.Write Entry(CStr(Time OfDay) + " started", EventLogEntryTy pe.Information)

AddHandler m_listTimer.Ela psed, AddressOf myTimerElapsed
m_listTimer.Ena bled = True
End Sub
When I start the service I see a new entry under...

Computer Management(loca l)
System Tools
Event Viewer
Application
MyServiceLog <--- new entry

But the actual event I write gets logged with the Application events.

My question is, can I get the events that I write to go under
MyServiceLog? What am I doing wrong?

TIA,

--

Dennis
Jun 27 '08 #1
2 1187
On May 20, 9:54 am, Dennis <nob...@nowhere .comwrote:
I have a service with the following startup code...
Protected Overrides Sub OnStart(ByVal args() As String)
If Not Diagnostics.Eve ntLog.SourceExi sts("MyService" ) Then
Diagnostics.Eve ntLog.CreateEve ntSource("MySer vice", "MyServiceL og")
End If
Dim _eventLog As New Diagnostics.Eve ntLog
_eventLog.Sourc e = "MyService"
_eventLog.Write Entry(CStr(Time OfDay) + " started", EventLogEntryTy pe.Information)
AddHandler m_listTimer.Ela psed, AddressOf myTimerElapsed
m_listTimer.Ena bled = True
End Sub

When I start the service I see a new entry under...

Computer Management(loca l)
System Tools
Event Viewer
Application
MyServiceLog <--- new entry

But the actual event I write gets logged with the Application events.

My question is, can I get the events that I write to go under
MyServiceLog? What am I doing wrong?

TIA,

--

Dennis
You're calling a Shared method from an instance variable, expecting it
to use your new event source. C# disallows this, but VB allows it.
There are overloads of the WriteEntry method that are not Shared, but
I think those only write to the default event log.

You need to call it like this:

Diagnostics.Eve ntLog.WriteEntr y("MyServiceLog ", CStr(TimeOfDay) + "
started", EventLogEntryTy pe.Information)

I hope this helps.

Chris

Jun 27 '08 #2
On Tue, 20 May 2008 11:16:57 -0700 (PDT), Chris Dunaway
<du******@gmail .comwrote:
>You're calling a Shared method from an instance variable, expecting it
to use your new event source. C# disallows this, but VB allows it.
There are overloads of the WriteEntry method that are not Shared, but
I think those only write to the default event log.

You need to call it like this:

Diagnostics.Ev entLog.WriteEnt ry("MyServiceLo g", CStr(TimeOfDay) + "
started", EventLogEntryTy pe.Information)

I hope this helps.
Thanks. All is now well...

--

Dennis
Jun 27 '08 #3

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

Similar topics

1
4120
by: Joe | last post by:
I am trying to read the EventLog of different servers on the network. If I run the script in a command line, it works well. But when I try to put the script into the Web server (IIS in Windows 2000) and run from a web browser, it works with my local machine only. I have the following error when I try to access any remote server: CGI Error The specified CGI application misbehaved by not returning a complete set of HTTP headers. The...
4
4626
by: Steven | last post by:
I just downloaded the June 2005 release and I want to set up basic logging to log problems such as exceptions. I have created a category named Exceptions with the following: <category name="Exceptions"> <destinations> <destination name="Event Log Destination" sink="Event Log Sink" format="Text Formatter" /> </destinations> </category>
2
3546
by: Next | last post by:
Hello all, I have a windows service that was suppose to write some events into its own EventLog. I created the EventLog using the component on VS 2003 toolbar Added an installer for it. Set all the appropriate properties to assign the new Source to a new log. For some reason installutil.exe created the source in the correct log. But
1
15990
by: martin | last post by:
Hi, I'm having some problems with the System.Diagnostics.EventLog class in .NET 2.0 I need to recreate an event message source inside a new log but the messages keeps ending up in the old log?! I have simplified my code into this tiny snippet: EventLog.CreateEventSource("mySrc", "myLog1");
8
6615
by: John | last post by:
Is there any special code I have to write to log event to Security Event Log? The following code give me "Very Easy Question, How to write log to SECURTY Event Log? Please help" Error // Create an EventLog instance and assign its source. EventLog myLog = new EventLog(); myLog.Source = "Security"; // Write an informational entry to the event log. myLog.WriteEntry("Writing warning to event log.",
3
4843
by: Ben | last post by:
I am trying to write an eventlog monitor. I am using the sample code provided by VB2005 SDK as the bases for my application. I need to monitor all three logs (application, system, and security). How can I monitor all three logs at once? Thanks,
2
2857
by: =?Utf-8?B?Sm9l?= | last post by:
I am trying to write to the EventLog from a WindowsService that I have written, however when I check to see if the Event Log exists (which it does) it fails. Here's the code. if (EventLog.SourceExists(this.szLogName.ToString()) == false) Here are all the iterations of the above that do not work: if (!EventLog.SourceExists(this.szLogName)) if (EventLog.SourceExists(this.szLogName) == false)
0
893
by: TonyJ | last post by:
Hello! Below is a snippet which doesn't work as expected. Here I create a custom event log named MyLog and a source named MyTest but when I look at the MyLog the column which should display the source is empty. It should have displayed MyTest because that is my source. It looks like this Typ Datum Tid Källa ... Information 2007-10-30 16:16:53
1
2047
by: Jeff | last post by:
hi ..Net 2.0 I've created the code below and think I've executed it. After I thought I've executed it I checked in EventLog on the computer (win2k3) and no entry was added. This could mean 2 things: - There are some logical errors in my code - The code wasn't actually executed
0
9454
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10268
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
10107
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...
0
9916
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6718
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
5486
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4017
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 we have to send another system
2
3611
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2853
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.