473,378 Members | 1,401 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,378 software developers and data experts.

EventLog does not write

Hi, I'm trying to write a eventlog in my Application_Error but does not work
I tryed by using SmtpMail and worked fine, but the EventLog not! =[

The code:

Exception ex = Server.GetLastError().GetBaseException();
string msgErro = ex.Message;
msgErro += "\n" + ex.StackTrace;

// Create the source, if it does not already exist.
if(!System.Diagnostics.EventLog.SourceExists("MySo urce", "MyServer"))
{
System.Diagnostics.EventLog.CreateEventSource("MyS ource", "MyNewLog",
"MyServer");
Console.WriteLine("CreatingEventSource");
}

// Create an EventLog instance and assign its source.
System.Diagnostics.EventLog myLog = new System.Diagnostics.EventLog();
myLog.Source = "MySource";

// Write an informational entry to the event log.
myLog.WriteEntry(msgErro);

--

Thanks in advance,

Daniel Groh
CTF Technologies do Brasil Ltda.
Analista Programador
Fone: 11 3837-4203
E-mail: dg***@ctf.com.br
Nov 19 '05 #1
2 2048
Hi,
This happens because of permission problems. Create event log source in the
installer class of the application.
Regards
Sambath

Cre"Paperback Writer" <ne*********@gmail.com> wrote in message
news:uU**************@TK2MSFTNGP10.phx.gbl...
Hi, I'm trying to write a eventlog in my Application_Error but does not
work I tryed by using SmtpMail and worked fine, but the EventLog not! =[

The code:

Exception ex = Server.GetLastError().GetBaseException();
string msgErro = ex.Message;
msgErro += "\n" + ex.StackTrace;

// Create the source, if it does not already exist.
if(!System.Diagnostics.EventLog.SourceExists("MySo urce", "MyServer"))
{
System.Diagnostics.EventLog.CreateEventSource("MyS ource", "MyNewLog",
"MyServer");
Console.WriteLine("CreatingEventSource");
}

// Create an EventLog instance and assign its source.
System.Diagnostics.EventLog myLog = new System.Diagnostics.EventLog();
myLog.Source = "MySource";

// Write an informational entry to the event log.
myLog.WriteEntry(msgErro);

--

Thanks in advance,

Daniel Groh
CTF Technologies do Brasil Ltda.
Analista Programador
Fone: 11 3837-4203
E-mail: dg***@ctf.com.br

Nov 19 '05 #2
Sorry but how do i use this installer class ?

"Sambathraj" <v_***********@hotmail.com> escreveu na mensagem
news:uR**************@TK2MSFTNGP10.phx.gbl...
Hi,
This happens because of permission problems. Create event log source in
the installer class of the application.
Regards
Sambath

Cre"Paperback Writer" <ne*********@gmail.com> wrote in message
news:uU**************@TK2MSFTNGP10.phx.gbl...
Hi, I'm trying to write a eventlog in my Application_Error but does not
work I tryed by using SmtpMail and worked fine, but the EventLog not! =[

The code:

Exception ex = Server.GetLastError().GetBaseException();
string msgErro = ex.Message;
msgErro += "\n" + ex.StackTrace;

// Create the source, if it does not already exist.
if(!System.Diagnostics.EventLog.SourceExists("MySo urce", "MyServer"))
{
System.Diagnostics.EventLog.CreateEventSource("MyS ource", "MyNewLog",
"MyServer");
Console.WriteLine("CreatingEventSource");
}

// Create an EventLog instance and assign its source.
System.Diagnostics.EventLog myLog = new System.Diagnostics.EventLog();
myLog.Source = "MySource";

// Write an informational entry to the event log.
myLog.WriteEntry(msgErro);

--

Thanks in advance,

Daniel Groh
CTF Technologies do Brasil Ltda.
Analista Programador
Fone: 11 3837-4203
E-mail: dg***@ctf.com.br


Nov 19 '05 #3

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

Similar topics

1
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...
5
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...
2
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...
6
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...
6
by: MattC | last post by:
I have some code that correctly writes to the eventlog on my local machine. I have installed the application on the Live server and all is not well, no event log entries. My development box...
3
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)....
2
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...
2
by: =?Utf-8?B?Sm9l?= | last post by:
I am trying to write to the EventLog from a WindowsService that I have written, however when I check to see if the Event Log exists (which it does) it fails. Here's the code. if...
1
by: Jacob | last post by:
I have the following code in a class... --------------------------------------------------------------------------------- .... Private _eL As EventLog = Nothing Private _eLName As String =...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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...
0
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$) { } ...
0
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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...

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.