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


  • Current version (12.03.2019)
  • Logs application errors/exceptions unhandled automatically.
  • Logs handled errors/exceptions if the user wants to do so in the exception catch block.
  • Logs messages given by the user at a point of code.
  • Logged errors go to a file called “%LOCALAPPDATA%\[Application product name]\trace_error.log”.
  • Logged messages go to a file called “%LOCALAPPDATA%\[Application product name]\app_messages.log”.
  • A thread that truncates the log from the beginning of the file to about 10000 lines depending on the next “MESSAGE BEGIN..” line hourly if necessary.
  • Full XML documentation is included (public/private)
  • A sample application is included (both WPF and WinForms).


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.


  • A Microsoft® Windows® supporting .NET Framework v.4.5 (possibly downgradable by modifying the source project settings)
  • LGPL v3 compatible application


  • v. (20.10.2015)
  • Fixed app_messages.log truncation on application start
  • Added product name and version to be logged as well
  • v. (12.03.2019)
  • Fixed file sharing issue if multiple instance of a same program were active


 A text editor showing trace_error.log file

 A text editor showing app_messages.log file

 A WPF sample application

Using in an application


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>
        static void Main()
            ExceptionLogger.Bind(); // bind before any visual objects are created
            Application.Run(new FormMain());
            ExceptionLogger.UnBind(); // unbind so the truncate thread is stopped successfully


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()
            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)
            // unbind so the truncate thread is stopped successfully