.NET Logging for Windows Forms, Console Applications and WPF
Feel free to donate to my PayPal.Me/xCONFLiCTiONx account. I work hard on these projects.
You can now backup the log file in x days. Example below...
.NET framework 4
// 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 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();
This project is licensed under the MIT License - see the LICENSE file for details