Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx thread: Event Logging


Message #1 by "Andrew Bradnan" <andrew@w...> on Mon, 9 Sep 2002 11:52:44 -0700
Has anyone stumbled across what permissions you need to eventlog now?  I 
keep getting "Requested registry access is not allowed."

I'm assuming this is a SP2 "fix", since I can't get anyone's example 
code to work.

Thanks,
Andrew Bradnan
www.whirlygigventures.com
Message #2 by "Oliver, Wells" <WOliver@l...> on Mon, 9 Sep 2002 12:43:29 -0700
Likewise. I gave up on custom eventlogs. It would be interesting to hear
anyone's tested solutions.

-----Original Message-----
From: Andrew Bradnan [mailto:andrew@w...] 
Sent: Monday, September 09, 2002 11:53 AM
To: ASP+
Subject: [aspx] Event Logging


Has anyone stumbled across what permissions you need to eventlog now?  I
keep getting "Requested registry access is not allowed."

I'm assuming this is a SP2 "fix", since I can't get anyone's example code to
work.

Thanks,
Andrew Bradnan
www.whirlygigventures.com

---

ASP.NET 1.0 Namespace Reference with C#
http://www.wrox.com/acon11.asp?ISBN=1861007442

ASP.NET 1.0 Namespace Reference with VB.NET
http://www.wrox.com/acon11.asp?ISBN=1861007450

These books are a complete reference to the ASP.NET namespaces 
for developers who are already familiar with using ASP.NET. 
There is no trivial introductory material or useless .NET 
hype and the presentation of the namespaces, in an easy-to use 
alphabetical order ensures a user-friendly reference format.
We provide in-depth coverage of all the major ASP.NET classes, 
giving you those real-world tips that the documentation doesn't 
offer, and demonstrating complex techniques with simple 
examples.  

---

Message #3 by "Dave Rezoski" <daverezoski@h...> on Mon, 09 Sep 2002 20:06:27 +0000
I have gotten this to work on a past project.  By default, the aspnet user 
has write access to an *existing* event log.  If you need to *create* and 
write to a log, then you need to use a user with admin privileges or give 
the aspnet user admin privileges - neither of these methods are suggested.

To determine what event logs already exist on my server I did the following: 
Open the event viewer, click on "Application", right-click & view 
properties... click the "Filter" tab, then drop down the "Event Source" 
drop-down list.  What you're looking at now is a list of event logs that 
already exist on the machine.  I chose the "Application" event log to write 
to.  C# example code follows, sorry in advance for poor formatting:

(I put my code in the global.asax.cs file for my purposes, within the 
Application_Error method)

protected void Application_Error(Object sender, EventArgs e)
{
	System.Exception ex = Server.GetLastError();
	string sError = "";

	// Create an EventLog instance and assign it's (existing)source.
	EventLog myLog = new EventLog();
	myLog.Source = "Application";

	if(ex == null)
	{
		myLog.WriteEntry("Unknown error occurred", EventLogEntryType.Error,0);
	}
	else
	{
	// Write an entry to the event log...
		if(ex.InnerException != null)
		{
		        sError += "InnerException.Message:\n" + ex.InnerException.Message 
+ "\n\n";
                        sError += "InnerException.Source:\n" + 
ex.InnerException.Source + "\n\n";
			sError += "InnerException.StackTrace:\n" + ex.InnerException.StackTrace + 
"\n\n";
		}
		sError += "Exception.Message:\n" + ex.Message + "\n\n";
		sError += "Exception.Source:\n" + ex.Source + "\n\n";
		sError += "Exception.StackTrace:\n" + ex.StackTrace + "\n\n";

		// write log
		myLog.WriteEntry(sError,EventLogEntryType.Error,0);

                // I also send email to myself with the above error info
	}
}


Good luck - let me know if this helps.



----Original Message Follows----
From: "Oliver, Wells" <WOliver@l...>
Reply-To: "ASP+" <aspx@p...>
To: "ASP+" <aspx@p...>
Subject: [aspx] RE: Event Logging
Date: Mon, 9 Sep 2002 12:43:29 -0700

Likewise. I gave up on custom eventlogs. It would be interesting to hear
anyone's tested solutions.

-----Original Message-----
From: Andrew Bradnan [mailto:andrew@w...]
Sent: Monday, September 09, 2002 11:53 AM
To: ASP+
Subject: [aspx] Event Logging


Has anyone stumbled across what permissions you need to eventlog now?  I
keep getting "Requested registry access is not allowed."

I'm assuming this is a SP2 "fix", since I can't get anyone's example code to
work.

Thanks,
Andrew Bradnan
www.whirlygigventures.com

---

ASP.NET 1.0 Namespace Reference with C#
http://www.wrox.com/acon11.asp?ISBN=1861007442

ASP.NET 1.0 Namespace Reference with VB.NET
http://www.wrox.com/acon11.asp?ISBN=1861007450

These books are a complete reference to the ASP.NET namespaces
for developers who are already familiar with using ASP.NET.
There is no trivial introductory material or useless .NET
hype and the presentation of the namespaces, in an easy-to use
alphabetical order ensures a user-friendly reference format.
We provide in-depth coverage of all the major ASP.NET classes,
giving you those real-world tips that the documentation doesn't
offer, and demonstrating complex techniques with simple
examples.

---


---

ASP.NET 1.0 Namespace Reference with C#
http://www.wrox.com/acon11.asp?ISBN=1861007442

ASP.NET 1.0 Namespace Reference with VB.NET
http://www.wrox.com/acon11.asp?ISBN=1861007450

These books are a complete reference to the ASP.NET namespaces
for developers who are already familiar with using ASP.NET.
There is no trivial introductory material or useless .NET
hype and the presentation of the namespaces, in an easy-to use
alphabetical order ensures a user-friendly reference format.
We provide in-depth coverage of all the major ASP.NET classes,
giving you those real-world tips that the documentation doesn't
offer, and demonstrating complex techniques with simple
examples.

---




_________________________________________________________________
MSN Photos is the easiest way to share and print your photos: 
http://photos.msn.com/support/worldwide.aspx


  Return to Index