473,320 Members | 2,177 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Viewing Event Log

Zen
Hi,

Would someone please point out where I can go to view the event log for the
following code? I thought it was the Event Viewer | Application in the
Computer Management but I didn't see it. thanks!

catch(Exception ex)

{

// Create a trace listener for the event log.

EventLogTraceListener myTraceListener = new
EventLogTraceListener("myEventLogSource");
// Add the event log trace listener to the collection.

Trace.Listeners.Add(myTraceListener);
// Write output to the event log.

Trace.WriteLine( string.Format( "Error: {0}", ex.Message ) );

}
Jan 10 '06 #1
2 1822
For what it's worth, I pasted in this slightly modified version of your
code into the Main method of a simple console application, and it
worked just fine:

try
{
throw new ApplicationException("my test error
message");
}
catch (ApplicationException ex)
{
EventLogTraceListener myTraceListener = new
EventLogTraceListener("myEventLogSource");
// Add the event log trace listener to the collection.
Trace.Listeners.Add(myTraceListener);
// Write output to the event log.
Trace.WriteLine(string.Format("Error: {0}",
ex.Message));
}
Note that I found the message by opening up my Event Viewer, and
clicking on the "Application" node. I found the message in the right
pane. It was written with a Type field of "Information" and a Source
field of "myEventLogSource"

In other words, as far as i can tell, your code is correct, and I think
you're looking in the same place I looked. Sorry I can't point to the
problem! It works on my machine.

Grasping at straws here:

1. have you tried refreshing the Event Viewer by pressing F5 just after
this code is run?

2. are you sure the code in question is being executed?

regards,
albert braun

Jan 10 '06 #2
Zen
I built the code in debug mode and it doesn't build the Trace.WriteLine
call. I looked at the disassembly during debugging session and that line
doesn't even exist. Is there any reason for that?

Thanks!


"albert braun" <bc***********************@yahoo.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
For what it's worth, I pasted in this slightly modified version of your
code into the Main method of a simple console application, and it
worked just fine:

try
{
throw new ApplicationException("my test error
message");
}
catch (ApplicationException ex)
{
EventLogTraceListener myTraceListener = new
EventLogTraceListener("myEventLogSource");
// Add the event log trace listener to the collection.
Trace.Listeners.Add(myTraceListener);
// Write output to the event log.
Trace.WriteLine(string.Format("Error: {0}",
ex.Message));
}
Note that I found the message by opening up my Event Viewer, and
clicking on the "Application" node. I found the message in the right
pane. It was written with a Type field of "Information" and a Source
field of "myEventLogSource"

In other words, as far as i can tell, your code is correct, and I think
you're looking in the same place I looked. Sorry I can't point to the
problem! It works on my machine.

Grasping at straws here:

1. have you tried refreshing the Event Viewer by pressing F5 just after
this code is run?

2. are you sure the code in question is being executed?

regards,
albert braun

Jan 10 '06 #3

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

Similar topics

1
by: Greg | last post by:
In my ASP.NET application I have a button that when pressed, data needs to be saved based on what the user typed in. I have other controls on the same page that should be updated as a result of the...
1
by: Greg | last post by:
In my ASP.NET application I have a button that when pressed, data needs to be saved based on what the user typed in. I have other controls on the same page that should be updated as a result of the...
2
by: crjunk | last post by:
I'm having problems viewing ASPX pages in the VS.NET browser. For some unknown reason, it just stooped working. The status bar at the bottom just says "Downloading...". So far I haven't been...
10
by: NH | last post by:
I have a girdview with paging enabled. How can I add a message in the footer to say "Viewing records 1-15 of 45" etc Thanks
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
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 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.