473,750 Members | 2,515 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

EventLog.Source & Service Programs

MAL
Hello,

I am writing a service program that writes to a custom EventLog. I
would like the two classes used in the service to write messages to
the same log ideally using a different Source name for filtering etc.

So far I am having little luck. I feel that I have been through the
documentation extensively but am chasing my tail. It seems like it
should be as simple as .CreateEventSou rce in each class I want to
write to the custom log, but to no avail.

When I tried to just add one class to the service program, the service
program wrote to the Application Log and the class wrote to the custom
one, even though the service seemed to have created the log. (Based on
a 5 minute timer before "Newing" my class) (.AutoLog = False) The code
is straight from the service program and EventLog walkthroughs (which
I end up using to clean things up (RemoveSource(s ), DeleteLog) before
my next service removal and reboot.

The last thing I tried was creating a seperate EventLog in each class
and trying to associate the source with the log the service created. I
have attemted to pass a reference to the EventLog to the classes and
then change the source like in the multithreaded examples. I have
tried to bring the service pgms EventLog into scope in the classes.
AHHHHHHH!!!

I am obviously making this harder that it needs to be.

Thanks for reading this rant. Please advise.
Nov 20 '05 #1
1 1669
In your OnStart function:

Dim log As EventLog

If Not EventLog.Source Exists("Service SourceNameOfYou rChoice") Then
EventLog.Create Source("Service SourceNameOfYou rChoice")
End If
log = New EventLog("Appli cation", "ServiceSourceN ameOfYourChoice ")

HTH

David Williams [VB.NET MVP]

"MAL" <ir************ *@hotmail.com> wrote in message
news:a2******** *************** **@posting.goog le.com:
Hello,

I am writing a service program that writes to a custom EventLog. I
would like the two classes used in the service to write messages to
the same log ideally using a different Source name for filtering etc.

So far I am having little luck. I feel that I have been through the
documentation extensively but am chasing my tail. It seems like it
should be as simple as .CreateEventSou rce in each class I want to
write to the custom log, but to no avail.

When I tried to just add one class to the service program, the service
program wrote to the Application Log and the class wrote to the custom
one, even though the service seemed to have created the log. (Based on
a 5 minute timer before "Newing" my class) (.AutoLog = False) The code
is straight from the service program and EventLog walkthroughs (which
I end up using to clean things up (RemoveSource(s ), DeleteLog) before
my next service removal and reboot.

The last thing I tried was creating a seperate EventLog in each class
and trying to associate the source with the log the service created. I
have attemted to pass a reference to the EventLog to the classes and
then change the source like in the multithreaded examples. I have
tried to bring the service pgms EventLog into scope in the classes.
AHHHHHHH!!!

I am obviously making this harder that it needs to be.

Thanks for reading this rant. Please advise.


Nov 20 '05 #2

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

Similar topics

1
2380
by: José Joye | last post by:
I know, this kind of question has already been asked. However, I could not find an answer related to the minimal privilege required to be able to create a new event Source in the appplication event log. I have a service app that needs to access shares (therefore, I cannot not start it using the System account). This service needs not to be run with particular privilege. So, I use a account member of users' group. Doing so will fail...
5
2336
by: timb | last post by:
Hi, am creating a windows service using c# and would like it to create a new eventlog logtype and add it to the eventlog viewer so that i can log all messages relating to this application to this specific log. Does anyone have any code for this which works as i have tried the examples but am unable to find the log in the eventlogviewer or anywhere on the hard drive afterwards. Thanks in advance TimB
2
3545
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
1724
by: McKool | last post by:
Hello. I'm making a Windows service with C#. This service connect a comm Port when start and disconnect it when stop. I use an EventLog class to write information about this service, by example, when the port get connect or disconnect. All work ok until the moment when the computer shutdown. If I stop the service manually before window shutdown, there is not any problem. If the service still run and windows is shutting down, the...
3
15632
by: John Lee | last post by:
Hi, we have been trying so many days and could not figure it out - please help!!! in windows 2003, we created an application pool and assigned a domain account as its identity - we also assigned this domain account to IIS_WPG group, and also assigned this domain account all priviledges that NETWORK SERVICE has in local security policy mmc ... but when we try to use System.Diagnosis.EventLog.WriteEntry("source", "test") we got access...
6
3740
by: Microsoft | last post by:
I'm creating a windows service with C#, but am having a huge amount of difficulties using the event log. In the design view of the service, I drop an EventLog component. I name the source the same as my service app and the log property I name with an appropriate name. However, this particular log never gets any entries, regardless of the AutoLog property. (In fact, I have the AUtoLog property set to false, but there are still log...
2
1559
by: John Smith | last post by:
I have created a windows service that logs errors to the EventLog. I want the logs to go to an EventLog I have created. However, I am finding that the event is not logging to the created EventLog instead it is logging to Application log. What could be the problem? ======================================================================== SYSTEM DETAILS: ======================================================================== ...
0
1016
by: pbh | last post by:
Hi all I've written a Service application and it must use it's own EventLog. The Service is checking if it is registered as EventLog source, and if not it creates it's own EventLog. Unfortunately the .NET installer program is registering my service as an standard Application EventLog source - making it impossible for my Service to have it's own EventLog (unless I delete the installer created EventLog registry entry after the installation of...
0
1415
by: Marcus Müller | last post by:
Hi, I'm using an user defined EventLog called "Fist Full of Lasers" within a C# service. The Log is created during the installation of the service in which the first entry of the log is written also. This works fine with Windows XPSP2. However, with Vista all entries are written in the Application-Log and not the "Fist Full of Lasers" Log: using System;
0
9001
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8839
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
9584
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
9398
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
9345
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
9257
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
8265
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
6811
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
4894
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.