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 5 2309
hi timb,
you can try this one, it will reflect on the application log.
using(EventLog oEL = new EventLog())
{
oEL.Source = "MyApps";
using(EventLogTraceListener oELT = new EventLogTraceListener())
{
oELT.EventLog = oEL;
oEL.WriteEntry("My EventLog Entry",EventLogEntryType.Information);
oELT.Flush();
}
}
EventLog and EventLogTraceListener is under System.Diagnostics.
hope this helps,
--
gani
pls visit www.thedeveloperscorner.com.ph
"timb" <ti**@nospam.com> wrote in message
news:ew*************@tk2msftngp13.phx.gbl... 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
Hi Gani,
i am able to write to the application log however i thought i
was possible to create a new log type which was displayed in the
evertviewer. i.e. different to application,system,security etc
thanks in advance
TimB
"gani" <a@a.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl... hi timb, you can try this one, it will reflect on the application log.
using(EventLog oEL = new EventLog()) { oEL.Source = "MyApps"; using(EventLogTraceListener oELT = new EventLogTraceListener()) { oELT.EventLog = oEL;
oEL.WriteEntry("My EventLog Entry",EventLogEntryType.Information); oELT.Flush(); } }
EventLog and EventLogTraceListener is under System.Diagnostics.
hope this helps, -- gani pls visit www.thedeveloperscorner.com.ph
"timb" <ti**@nospam.com> wrote in message news:ew*************@tk2msftngp13.phx.gbl... 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
Hi,
You can check my article at code project (sample source is in VB.NET) http://www.codeproject.com/dotnet/evtvwr.asp
This talks about creating and using custom event logs, sources and
categories.
BTW, this is a simple code snippet to just create a new source and a new
log:
objEventLog.CreateEventSource("MySource","MyLog")
--
HTH,
Manoj G [.NET MVP] http://www15.brinkster.com/manoj4dotnet
"timb" <ti**@nospam.com> wrote in message
news:ew*************@tk2msftngp13.phx.gbl... 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
Hi,
Have tried this code and similar c# code from the help file and it works
no problems unless i try and run it from a windows service. I have tried
setting the service to run under an account which has administrator rights
on the local machine but this doesnt seem to help. Any ideas?
"timb" <ti**@nospam.com> wrote in message
news:OQ**************@TK2MSFTNGP11.phx.gbl... Hi Gani, i am able to write to the application log however i thought i was possible to create a new log type which was displayed in the evertviewer. i.e. different to application,system,security etc
thanks in advance TimB
"gani" <a@a.com> wrote in message news:%2***************@TK2MSFTNGP09.phx.gbl... hi timb, you can try this one, it will reflect on the application log.
using(EventLog oEL = new EventLog()) { oEL.Source = "MyApps"; using(EventLogTraceListener oELT = new EventLogTraceListener()) { oELT.EventLog = oEL;
oEL.WriteEntry("My EventLog Entry",EventLogEntryType.Information); oELT.Flush(); } }
EventLog and EventLogTraceListener is under System.Diagnostics.
hope this helps, -- gani pls visit www.thedeveloperscorner.com.ph
"timb" <ti**@nospam.com> wrote in message news:ew*************@tk2msftngp13.phx.gbl... 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
Did you ever get a satisfactory reply to this problem, I would be interested to hear about a cure as I am also miffed by this.
Thanks
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
by: Erick |
last post by:
Hi,
Does any one know how to avoid to register of the event
log source by the TransactedInstaller object?
I have a service which have some code into the main method
to self-register base on...
|
by: Jacob Colding |
last post by:
Hello,
I have created a a logging mechanism, that writes mesages to a custom event
log. On each check it verifies whether the requested source is registered to
the "IPS" log. If not, it changes...
|
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...
|
by: MAL |
last post by:
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...
|
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...
|
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)....
|
by: rene |
last post by:
I'm trying to use costome categories in my eventlog for a program I'm
writing.
But I have some problems with it, I cant get it to work. Checklist for
how I did this.
1. Created a...
|
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...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |