Tim,
Certain tasks in .NET need some security privilege to perform them.
You should have a window app or console app that creates the EventLogs and
the EventSources your app uses. This should be executed by some
administrator (usualy the Operations department). Then your windows service
would be able to log events successfully.
The same problem you would have if your app was an aspx.
This is all by design. It is part of the security provision. Admins (highly
trusted accounts) should first install and create whatever will later be
used by Apps (less trusted accounts).
--
Thanks.
Paulo
DISCLAIMER: This posting is provided "AS IS" with no warranties, and confers
no rights. Use of any included code samples are subject to the terms
specified at http://www.microsoft.com/info/cpyright.htm"
"timb" <ti**@nospam.com> wrote in message
news:uR**************@TK2MSFTNGP10.phx.gbl...
Hi,
does any have any sample code of the above?
i have tried the example from the help but am unable to get my windows
service to create a new logfile and start logging to it.
I am able to create one however if my application is a windows form
application.
Thanks in advance
TimB
public UserService2()
{
this.AutoLog = false;
// create an event source, specifying the name of a log that
// does not currently exist to create a new, custom log
if (!System.Diagnostics.EventLog.SourceExists("MySour ce"))
{
System.Diagnostics.EventLog.CreateEventSource(
"MySource","MyLog");
}
// configure the event log instance to use this source name
eventLog1.Source = "MySource";
}
protected override void OnStart(string[] args)
{
// write an entry to the log
eventLog1.WriteEntry("In OnStart.");
}