Print

ErrorLogger

A .NET Framework library for logging application errors (handled/unhandled) and messages the application "want's" to log.

 

Features

Notes

I developed this library while tracing the bug that lead to a crash of the SimpleBackup software because of the missing Visual C++ Redistributable Package.

 

Requirements

 

Changes

 

Screenshots

 A text editor showing trace_error.log file

 

 A text editor showing app_messages.log file

 

 A WPF sample application

 

 

 

Using in an application

WinForms

The library in WinForms must be "bound" before any forms are created (Program.cs).

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using VPKSoft.ErrorLogger; // reguired

namespace WinFormsTest
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            ExceptionLogger.Bind(); // bind before any visual objects are created
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new FormMain());
            ExceptionLogger.UnBind(); // unbind so the truncate thread is stopped successfully
        }
    }
}

 

WPF

The library can be "bound" in the main window constructor.

using VPKSoft.ErrorLogger; // reguired

namespace WPFTest
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            ExceptionLogger.Bind(); // bind
            ExceptionLogger.LogMessage("Application start: " + System.Windows.Application.ResourceAssembly.GetName().Name);
        }

The library can be "unbound" in the main window's Closing event.

private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            ExceptionLogger.UnBind();
// unbind so the truncate thread is stopped successfully
}

 

Download

Source, GitHub

NuGet