Skip to content

.NET Logging for Windows Forms, Console Applications and WPF

License

Notifications You must be signed in to change notification settings

xCONFLiCTiONx/EasyLogger

Repository files navigation

EasyLogger

.NET Logging for Windows Forms, Console Applications and WPF

EasyLogger NuGet Package nuget Downloads GitHub stars

Donations

Feel free to donate to my PayPal.Me/xCONFLiCTiONx account. I work hard on these projects.

Latest changes

You can now backup the log file in x days. Example below...

Prerequisites

.NET framework 4

How to use the Logger

// Backup immediately
EasyLogger.BackupLogs(EasyLogger.LogFile);

// OR Backup if the log file is older than x days
EasyLogger.BackupLogs(EasyLogger.LogFile, 30);

Add a listener to enable logging using the default location.
The default location is [SystemDrive]\ProgramData\EasyLogger\[ApplicationName]\[UserName]\[ApplicationName].log

// Initiate logging
EasyLogger.AddListener(EasyLogger.LogFile);

Log some quick information.

// Log something
EasyLogger.Info("Log something...");

2020-02-02 14:23:27 [info] Log something...

Stop Logging and Set Log Location

Stop the listener and disable logging.

// Dispose of the logger
EasyLogger.RemoveListener();

Set a custom location for the log file.

// Backup custom log path
var CustomLog = AppDomain.CurrentDomain.BaseDirectory + "LOGGING" + "\\TEST.log";
EasyLogger.BackupLogs(CustomLog);

Add a listener to enable logging using a custom location.

// Initiate logging with a custom log path
EasyLogger.AddListener(CustomLog);

Used to log information

// Log something
EasyLogger.Info("Log something...");

2020-02-02 14:23:27 [info] Log something...

Used to log warnings

// Log a warning
EasyLogger.Warning("Don't forget to dispose!");

2020-02-02 14:23:27 [warning] Don't forget to dispose!

Used to log errors

// Log an issue
EasyLogger.Error(ex);

2020-02-02 14:23:27 [error] some error such as Object Reference not set to an instance of an Object.

To disable logging and dispose.

// Dispose of the logger
EasyLogger.RemoveListener();

License

This project is licensed under the MIT License - see the LICENSE file for details

About

.NET Logging for Windows Forms, Console Applications and WPF

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages