This Documentation is for the V3.0  

To use CatchThatException library, make sure you add a reference for it in you project.

After that all what you need to do is just call the class in it's name and call the static method logException. Make sure you but a try catch statement around your code you want to check for exceptions and then pass the exception as a parameter and also the log path.

Also, please set the right property before you use the method. Ex:

To log for access you need to set the .mdb file location By:

 

 

CatchThatException.LogAccess�=�"d:\\LogDB.mdb";

 

 

Then you can use the method to log the exception:

 

 

CatchThatException.LogErrorMSAccess(ex);

 

1-Logging to text file:

You need to set the path to write text file:

CatchThatException.LogPath = "d:\\tr.txt";

Then you can call the method to write the exception to the text file:

CatchThatException.LogErrorTxt(ex);

 

2-Logging to MS Access Database:

You need to set the path for the MS Access Database(Included with the downloaded File LogDB.mdb)

CatchThatException.LogAccess = "d:\\LogDB.mdb";

Then you call the method to write to the Access file:

CatchThatException.LogErrorMSAccess(ex);

 

3-Logging to SMTP:

You need to set the following values :

 
CatchThatException.Fromadderss ="test@ex.com";
CatchThatException.Host = "mail.test.com";
CatchThatException.Port =25;
CatchThatException.Username ="username";
CatchThatException.Password="pass";
CatchThatException.ToAddress="reciver@test.com";

 

Then you can call The SMTP Method so you can email the exception:

CatchThatException.newLogSMTP(ts);

 

4-Logging to SQL Server:

Note that there is a stored procedure and table script included with the downloaded file. Execute Them on your Sql Server.

You need to set the connection string for the 

CatchThatException.SqlServer = "Your connection string here":

Then you can call the method to log it to the Sql Server:

CatchThatException.LogErrorMSSQL(ex);

 

To pass exception data with the exception Just name the key and give it a Value:

try
{
Exception tt = new Exception();
throw tt;
 
}
catch(Exception ts)
{
ts.Data["amr"]="test";
ts.Data["aaa"]="aaa";
CatchThatException.LogErrorText(ts);

}

 

And you will see the keys and it's value in the log file.

 

To Use Debug and Info

You need to turn them on to log:

 

CatchThatException.Infoon = true;
CatchThatException.Debugon = true;

 

Then yo can call the methods to log them:

 

 


CatchThatException.Debugtext("test debug"); //To log debug into the Text
CatchThatException.Infotext("Info for text");//To log info into text
CatchThatException.DebugAccess("testing debug access"); //To log debug into access
CatchThatException.InfoAccess("testing info access"); //To log info to Access
CatchThatException.InfoSMTP("Testing info for smtp"); //to log info for smtp
CatchThatException.DebugSMTP("Testing debug for Smtp");//To log debug for SMTP

Last edited Aug 5, 2013 at 12:56 PM by amrswalhadp, version 10

Comments

No comments yet.