p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

aspdotnet_website_programming thread: RE :LogEvent & AppExceptiion workarounds


Message #1 by "Blue Tiger" <bluetiger@m...> on Wed, 12 Feb 2003 17:18:47 -0500
Is the Access database separate from the SQL database for the Web
Application?
I searched the archives and located this example (slightly modified from
Doni Grande):
private void LogEvent(string message)
{
//	if (!EventLog.SourceExists("TestNet"))
//	{
//		EventLog.CreateEventSource("TestNet", "Application");
//	}
//	EventLog.WriteEntry("TestNet", message, EventLogEntryType.Error);

	private string logFilename =3D @"/website/ErrorLog.txt";

	string currenttime =3D DateTime.Now.ToLongDateString() + " " +
DateTime.Now.ToLongTimeString();
	HttpContext context =3D HttpContext.Current;
	string fullpath =3D context.Request.MapPath(logFilename);
	TextWriter output =3D File.AppendText(fullpath);
	output.WriteLine("new error event: + <br />");
	output.WriteLine(currenttime);
	output.WriteLine(message);
	output.Close();
}

He also says to "change the ThePhilePage.cs to use the LogEvent from
AppException instead of re-inventing the wheel." I'm still having 
problems
though.I can easily use either an Access database (or SQL), but would 
prefer
the text option. I can't seem to wrap my head around what code I need to
modify in the AppException class (I'm still a newbie).

Thanks for all the help,
Ryan

-----Original Message-----
From: Joshi, Sunit [mailto:sjoshi@i...]
Sent: Wednesday, February 12, 2003 8:51 AM
To: Website Programming with ASP.NET
Subject: [aspdotnet_website_programming] RE: 
[aspdotnet_website_programmin
g]

I log errors to an Access Database. This is what I do in the LogEvent 
method

private void LogEvent(string message, EventLogEntryType entryType)
{
 Skm.Accounts.AccountsBusiness.SitePrincipal sp =3D
                new
Skm.Accounts.AccountsBusiness.SitePrincipal("admin@s...");
 Skm.Accounts.AccountsBusiness.SiteIdentity sid =3D
               (Skm.Accounts.AccountsBusiness.SiteIdentity)sp.Identity;
		=09
 string connectionString =3D sid.ConnectionString;
 Skm.Accounts.AccountsData.RunQuery oRun =3D
            new Skm.Accounts.AccountsData.RunQuery(connectionString);

 oRun.LogError(message, "SkmPageBase", "BaseUser", 
DateTime.Now.ToString());
}

Sunit

-----Original Message-----
From: Blue Tiger [mailto:bluetiger@m...]
Sent: Wednesday, February 12, 2003 1:31 AM
To: Website Programming with ASP.NET
Subject: [aspdotnet_website_programming] [aspdotnet_website_programming]


Also,
	When reading the book, I noticed that the AppException is dependent
on EventViewer. Since I use a hosting provider, I don't have access to 
the
EventLog. How can I rewrite the method to log errors in a text file 
within
my folders? (see AppException class for example)
The other idea is to remove instances of AppException tracing in the 
rest of
the code (but I'm unsure how many instances of this are there & I still 
want
to know the errors...soooo)
Any help on this would be greatly appreciated.

Thanks,
Ryan



---
Professional Design Patterns in VB.NET:
Building Adaptable Applications

Want to know how design patterns bring reusable
design and adaptabilty to your applications? How
to recognize the need for a design pattern
solution? How to select, design, and implement
the right patterns? How parts of the .NET Framework
(like the .NET Data Providers and .NET Remoting)
take advantage of design patterns? This book
presents a practical approach to using design
patterns in VB.NET, by focusing on the relevance
of design patterns in the different tiers of a
distributed n-tier architecture.

http://www.wrox.com/books/1861006985.htm


---
Professional Design Patterns in VB.NET:
Building Adaptable Applications

Want to know how design patterns bring reusable
design and adaptabilty to your applications? How
to recognize the need for a design pattern
solution? How to select, design, and implement
the right patterns? How parts of the .NET Framework
(like the .NET Data Providers and .NET Remoting)
take advantage of design patterns? This book
presents a practical approach to using design
patterns in VB.NET, by focusing on the relevance
of design patterns in the different tiers of a
distributed n-tier architecture.

http://www.wrox.com/books/1861006985.htm



  Return to Index