Hi All,
I am getting Some errors in my application.
Now i need to log that error into notepad through my catch my block
how can i achieve this
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Ankit Shivnakr87 reputationPosted Jan 10, 2012, 2:12 AM EST
Shiv Try this code
try
{
// Your code plase
}
catch (Exception exception2)
Pravin GhadgeRank #1,340 · 1.3K reputationPosted Jan 10, 2012, 2:14 AM EST
catch (Exception ex)
{
writeFile(ex.Message);
}
public void writeFile(string strWrite)
{
FileStream fs = new FileStream(@"c:\Temp\tmp.txt", FileMode.OpenOrCreate, FileAccess.Write);
StreamWriter m_streamWriter = new StreamWriter(fs);
m_streamWriter.BaseStream.Seek(0, SeekOrigin.End);
m_streamWriter.WriteLine(strWrite);
m_streamWriter.Flush();
m_streamWriter.Close();
}
Anuja PawarRank #1,404 · 1.2K reputationPosted Jan 10, 2012, 2:35 AM EST
Refer this article for complete guidance
http://imar.spaanjaars.com/275/logging-errors-to-the-event-log-in-aspnet-applications
SIVARank #2,303 · 613 reputationPosted Jan 10, 2012, 3:05 AM EST