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

WriteEntry to Event Log Fails

TJO
I am creating an EventLog and attempting to write to it using the
following code. The problem is when I inspect the log there in no
entry? Can anyone see what I am doing wrong here?
if (!System.Diagnostics.EventLog.SourceExists("SmartM I"))
{
System.Diagnostics.EventLog.CreateEventSource(
"SmartMI", "SmartMILog");
}

EventLog EventLog1 = new
EventLog("SmartMILog",System.Environment.MachineNa me, "SmartMI");

string msg = "Foo Bar";

EventLog1.WriteEntry(msg);

Nov 19 '05 #1
2 1763
To create a Source you must have special permissions.
ASP.NET account does not have those permissions.

Solution is simple. Write small executable with one line
System.Diagnostics.EventLog.CreateEventSource("Sma rtMI", "SmartMILog");

Have an admin to run it.

Kill this 4 lines from your ASP.NET code
if (!System.Diagnostics.EventLog.SourceExists("SmartM I"))
{
System.Diagnostics.EventLog.CreateEventSource(
"SmartMI", "SmartMILog");
}
George

"TJO" <Ti**********@gmail.com> wrote in message news:11**********************@o13g2000cwo.googlegr oups.com...
I am creating an EventLog and attempting to write to it using the
following code. The problem is when I inspect the log there in no
entry? Can anyone see what I am doing wrong here?
if (!System.Diagnostics.EventLog.SourceExists("SmartM I"))
{
System.Diagnostics.EventLog.CreateEventSource(
"SmartMI", "SmartMILog");
}

EventLog EventLog1 = new
EventLog("SmartMILog",System.Environment.MachineNa me, "SmartMI");

string msg = "Foo Bar";

EventLog1.WriteEntry(msg);

Nov 19 '05 #2
TJO
Thanks for helping on this but there is some information I should tell
you.
This code resides in a windows application operating under
Administrator role, so permissions are not an issue with this code
sample.

I still don't see my log entries after caling the WriteEntry().

Nov 19 '05 #3

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

Similar topics

1
by: Ray Cassick \(Home\) | last post by:
I noticed that when I write an entry into the Windows event log using one of the various overloaded WriteEntry methods I always get the following text below my description: For more information,...
0
by: Colin Halliday | last post by:
A number of the overloaded forms of the eventlog.writeentry method allow for an event log entry CATEGORY (a short numeric). The help for this method states: 'Each application can define its...
0
by: Steve DeLong | last post by:
I have a set of C++ applications that all use a common message DLL. I am working on a .NET Service that I would also like to use this same message DLL. From what I have read, this should work...
3
by: John Lee | last post by:
Hi, we have been trying so many days and could not figure it out - please help!!! in windows 2003, we created an application pool and assigned a domain account as its identity - we also...
0
by: Colin Halliday | last post by:
A number of the overloaded forms of the eventlog.writeentry method allow for an event log entry CATEGORY (a short). The help for this method states: 'Each application can define its own...
3
by: Dachshund Digital | last post by:
Has any one figured out how to override the WriteEntry or show change the actual output? I am sorry, but putting the DATE/TIME PROCESS # and Thread # information AFTER the 'Message' text just...
0
by: eric.goforth | last post by:
Hello, I'm trying to write information out to a log file, I think that I'm missing something in my app.config file. I've put the following in there: <?xml version="1.0" encoding="utf-8" ?>...
0
by: jammendolia | last post by:
Hello all, I am having an intermittent exception occur when writing the the eventlog from a windows service application written in c#, running on a Win2k SP4 server. Here's the code: ...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.