Click here to Skip to main content
15,867,756 members
Articles / Programming Languages / C#

Small and easy bug report system

Rate me:
Please Sign up or sign in to vote.
4.60/5 (5 votes)
16 Jan 2009CPOL 37.8K   464   50   11
A very small and easy C# + PHP bug report system.

Code

Introduction

A small bug tracking system, easy to implement and efficient.

Background

The system uses a PHP file and a SQLite database on a remote server to read and write errors captured.

Using the Code

To send an error, you simply have to make a POST request to the file bugs.php, specifying the parameters "program", "error", and "text". For example, to send all the non captured Exceptions in a program, you could do something like this:

C#
[STAThread]
static void Main()
{
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);

    Application.ThreadException +=
      new
System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
    AppDomain.CurrentDomain.UnhandledException +=
      new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

    Application.Run(new Form1());
}

static void Application_ThreadException(object sender,
            System.Threading.ThreadExceptionEventArgs e) {
    SendException(e.Exception);
}

static void CurrentDomain_UnhandledException(object sender,
                          UnhandledExceptionEventArgs e) {
    SendException((Exception)e.ExceptionObject);
}

static void SendException(Exception error) {
    System.Net.WebClient webclient = new System.Net.WebClient();
    System.Collections.Specialized.NameValueCollection postData =
               new System.Collections.Specialized.NameValueCollection(5);

    postData.Add("program", "Example version " +
                 Application.ProductVersion);
    postData.Add("error", error.GetType().Name);
    postData.Add("text", error.ToString());

    webclient.UploadValues(new
Uri("http://www.example.com/bugs.php"), postData); }

To know the errors that have been sent, you can access them easily through any RSS reader, which allows viewing in a short time, and easily and conveniently. For example, if your PHP file is in www.example.com/bugs.php, you can add that URL to your favorite feed reader to keep informed of the errors that occurs in your application.

Update

Now you can set a password in the PHP file to prevent anyone can read the error log. Furthermore, it has functionality to delete individual records or the complete database.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
CEO
Spain Spain
I'm a young entrepreneur from Cartagena (Spain). I'm the creator and owner of some popular websites like Chuletas and Wikiteka.

Currently, I'm working on Ideatic, a company for Internet and software develop.

Comments and Discussions

 
BugSqlite not available on new php versions - SQLITE3 support Pin
Mystery12315-Dec-20 5:08
professionalMystery12315-Dec-20 5:08 
QuestionEnter - '\n' ? Pin
Mystery12313-Jan-09 20:30
professionalMystery12313-Jan-09 20:30 
AnswerRe: Enter - '\n' ? Pin
Fco. Javier Marin13-Jan-09 23:59
Fco. Javier Marin13-Jan-09 23:59 
GeneralRe: Enter - '\n' ? Pin
Mystery12314-Jan-09 1:13
professionalMystery12314-Jan-09 1:13 
AnswerRe: Enter - '\n' ? Pin
Mario_F20-Jan-09 14:32
Mario_F20-Jan-09 14:32 
GeneralArticle Pin
Nedim Sabic11-Jan-09 23:55
Nedim Sabic11-Jan-09 23:55 
GeneralRe: Article Pin
Fco. Javier Marin12-Jan-09 0:02
Fco. Javier Marin12-Jan-09 0:02 
GeneralNo internet connection Pin
Johnny J.11-Jan-09 0:05
professionalJohnny J.11-Jan-09 0:05 
GeneralRe: No internet connection Pin
Fco. Javier Marin11-Jan-09 0:10
Fco. Javier Marin11-Jan-09 0:10 
QuestionWhy PHP? Pin
bobfox10-Jan-09 10:45
professionalbobfox10-Jan-09 10:45 
AnswerRe: Why PHP? Pin
Fco. Javier Marin10-Jan-09 23:14
Fco. Javier Marin10-Jan-09 23:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.