Tutorials
Resources
Forum
Reviews
Communities
Interview
Jobs
Projects
Training
Your
Ad
Here
Silverlight Games
|
Mentor
|
Code Converter
|
Articles
|
Code Factory
|
Computer Jokes
|
Members
|
Peer Appraisal
|
IT Companies
|
Bookmarks
|
Polls
|
Revenue Sharing
|
Lobby
|
Gift Shop
|
Prizes & Awards
My Profile
Sign In
Register
AdSense Revenue
Active Members
Today
Pawan
(80)
Deepika Harida...
(57)
Prafulla
(52)
Last 7 Days
Alwyn
(739)
nishithraj
(512)
Manindra Upadh...
(438)
more...
Resources
»
Code Snippets
»
ASP.NET WebForms
»
Error Logging using ASP.NET 2.0
Posted Date: 03 Dec 2008
Resource Type:
Code Snippets
Category:
ASP.NET WebForms
Author:
sabeer masthan
Member Level:
Gold
Rating:
Points
: 5
public static void WriteError(string errorMessage)
{
try
{
string path = "~/Error/" + DateTime.Today.ToString("dd-mm-yy") + ".txt";
if (!File.Exists(System.Web.HttpContext.Current.Server.MapPath(path)))
{
File.Create(System.Web.HttpContext.Current.Server.MapPath(path)).Close();
}
using (StreamWriter w = File.AppendText(System.Web.HttpContext.Current.Server.MapPath(path)))
{
w.WriteLine("\r\nLog Entry : ");
w.WriteLine("{0}", DateTime.Now.ToString(CultureInfo.InvariantCulture));
string err = "Error in: " + System.Web.HttpContext.Current.Request.Url.ToString() +
". Error Message:" + errorMessage;
w.WriteLine(err);
w.WriteLine("__________________________");
w.Flush();
w.Close();
}
}
catch (Exception ex)
{
WriteError(ex.Message);
}
}
Responses
No responses found. Be the first to respond and make money from
revenue sharing program
.
Feedbacks
Popular Tags
What are tags ?
Search Tags
Sign In
to add tags.
Interview Skills
.
Post Feedback
This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must
Sign In
to post a response.
Next Resource:
Using query string for data retrieval
Previous Resource:
Redirecting users on unhandled errors
Return to Discussion Resource Index
Post New Resource
Category:
ASP.NET WebForms
Post resources and
earn money
!
More Resources
Using query string for data retrieval
Decrypt Function in C# .Net
Difference between two dates in ASP.Net using VB.net
ASP.NET Validation Controls
Caching
WebServices
dotNet Slackers
About Us
Contact Us
Privacy Policy
Terms Of Use