473,734 Members | 3,306 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Service that writes to the application Event Log

Hello. I am writing a service that I would like to have write access to
the Application event log. Since the service is running as a system
account, it would appear that I do not have access. (Security Error).

I am following the MSDN howto and it does not appear to have any
additional requirements in their howto.

If I run this as an application under my credentials (local admin) it
runs just fine.

I have a feeling this is realted to XP SP2 or Perhaps .Net 1.1

Advice?
Thanks in advance!
-Aaron
Dec 20 '05 #1
4 2223
Hi,
"Aaron Hackney" <ah************ ****@grics.net> wrote in message
news:do******** *@enews2.newsgu y.com...
Hello. I am writing a service that I would like to have write access to
the Application event log. Since the service is running as a system
account, it would appear that I do not have access. (Security Error).
I do not think so, IIRC everybody can write in the log

Post your code just to be sure it's correct.
I have a feeling this is realted to XP SP2 or Perhaps .Net 1.1


Not at all, the problem should be in something else you are trying to do,
post your code !

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Dec 20 '05 #2
You should only need admin rights to create a new log or log source. If
you are writing to an existing log with an existing log source, it
should work. If you need to create a new log or source, it is best to do
it during deployment by making an Installer class (which you can execute
using InstallUtil.exe ). Do not require your application to run as an
admin just to create the event log/source.
Dec 21 '05 #3
Ignacio Machin ( .NET/ C# MVP ) wrote:
Hi,
"Aaron Hackney" <ah************ ****@grics.net> wrote in message
news:do******** *@enews2.newsgu y.com...
Hello. I am writing a service that I would like to have write access to
the Application event log. Since the service is running as a system
account, it would appear that I do not have access. (Security Error).

I do not think so, IIRC everybody can write in the log

Post your code just to be sure it's correct.
I have a feeling this is realted to XP SP2 or Perhaps .Net 1.1

Not at all, the problem should be in something else you are trying to do,
post your code !

I've muched with the code a bit but I was following directions from MSDN
here:
http://msdn.microsoft.com/library/de...pplication.asp

Thanks much
-Aaron

using System;
using System.Collecti ons;
using System.Componen tModel;
using System.Data;
using System.Diagnost ics;
using System.ServiceP rocess;

namespace MyNewService
{
public class MyNewService : System.ServiceP rocess.ServiceB ase
{
private System.Diagnost ics.EventLog eventLog1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.Componen tModel.Containe r components = null;

public MyNewService()
{
// This call is required by the Windows.Forms Component Designer.
InitializeCompo nent();
}

// The main entry point for the process
static void Main()
{
System.ServiceP rocess.ServiceB ase[] ServicesToRun;

// More than one user Service may run within the same process. To add
// another service to this process, change the following line to
// create a second service object. For example,
//
// ServicesToRun = new System.ServiceP rocess.ServiceB ase[] {new
Service1(), new MySecondUserSer vice()};
//
ServicesToRun = new System.ServiceP rocess.ServiceB ase[] { new
MyNewService() };

System.ServiceP rocess.ServiceB ase.Run(Service sToRun);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.eventLog1 = new System.Diagnost ics.EventLog();
((System.Compon entModel.ISuppo rtInitialize)(t his.eventLog1)) .BeginInit();
//
// eventLog1
//
this.eventLog1. Log = "System";
this.eventLog1. MachineName = "skinner";
((System.Compon entModel.ISuppo rtInitialize)(t his.eventLog1)) .EndInit();

}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Disp ose();
}
}
base.Dispose( disposing );
}

/// <summary>
/// Set things in motion so your service can do its work.
/// </summary>
protected override void OnStart(string[] args)
{
eventLog1.Write Entry("In OnStart");
}

/// <summary>
/// Stop this service.
/// </summary>
protected override void OnStop()
{
eventLog1.Write Entry("In onStop.");
}

protected override void OnContinue()
{
eventLog1.Write Entry("In OnContinue.");
}
}
}
Dec 21 '05 #4
I found my problem/answer. By default loggin is turned on and allow
without registering or creating a source.

I just needed to use the static methods provided such as
EventLog.WriteE ntry instead of creating an instance of
System.Diagnost ics.EventLog()

*DOH*

Dec 30 '05 #5

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

Similar topics

8
2031
by: Fabio Papa | last post by:
I am trying to write a windows service that sends emails to clients at specific times based on information in a sql db. Since this is done for multiple cities, I start a thread for each city and continue the processing from each thread. My service starts fine (gives me no errors, etc), but it doesn't seem to start the new threads. I am new to windows services, so I don't know if I'm doing something wrong. Should I maybe be doing this...
3
7837
by: Craig Thompson | last post by:
I've attempted to write a windows service that creates one FileSystemWatcher for each entry in a XML config file. Everything start perfrectly and runs as I expect for about 5 minutes and then after that the FileSystemWatchers seem to stop monitoring... My theory is that for some reason the Garbage Collector is trashing my FileSystemWatchers. Another clue to my situation is that I just took my service and made it into a windows form...
2
21910
by: Mark | last post by:
I created an extremely simple windows service that only writes to the EventLogs on Stop and Pause. I installed it using the InstallUtil.exe program, the output of which is below. It appears to be successful. I'm now ready to start my service (I think) but the NET START command does not appear to indicate that the service is available to be run. The output for NET START is below as well. The Services list in the W2K administrator...
5
1587
by: John | last post by:
Hi I am trying to get web reference to my first (!) web service which is on a remote host. I am getting the following error; Server Error in '/' Application. Runtime Error Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application
3
3561
by: bclegg | last post by:
Hi, I am trying to use a 3rd Party telephony (Intel's CT-ADE 8.3) library in a vb.net service. The way it hangs up is to raise an Event. If you build a windows Application you can write: Sub DoSomeWork While not Hungup Do lots of good things application.doevents end While
2
2650
by: Randall Powell | last post by:
I am in the process of developing a Windows Service which will: (1) monitor multiple network shares; (2) marshal text file transfers into an SQL Server 2000 instance; and (3) provide messaging services via email and a customized event log viewer. An additional goal is to have the service provide a visual status indicator via an icon to be located in the Taskbar status area. The NotifyIcon component appears to be a logical candidate and worked...
27
4719
by: pisquem | last post by:
I am building an windows service that is to be deployed on a windows server 2003 and I want to have activity written to the event log, I want its own log called ('CustomLog') Below is what I have so far...its builds fine but when I go to start the service i get the following error. --------------------------- Services ---------------------------
0
1495
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...
7
2280
by: Diego F. | last post by:
Hello. I have a windows service running that listens to a port and makes insert queries in a database. I need to make an interface, so my idea is creating a simple windows application that just shows messages from the service. Can I do that with remoting? What are the main steps to do that? --
0
8957
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...
1
9248
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
9193
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
8194
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
6745
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
6043
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
4819
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2185
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.