-
Notifications
You must be signed in to change notification settings - Fork 0
Home
SimpleLogToFile is very easy to use as you can set only a few parameters and include the static class to get it to work, the default parameters are fine for already many applications
The log files are created in a subfolder of the application's Working Directory
_logSubfolder allows you to specify the name of the subfolder
Example:
You run the application from "C:\Program Files\Test App"
_logSubfolder="Logs"
Your log files are created in "C:\Program Files\Test App\Logs"
The log file name is the result of the following paramenters:
_logPrefix-_logDateFormat._logExtension
This system allows to have a new log file automatically created depending on the format of the date, so if for example you want a daily log file you can change the format to "yyyyMMdd", or if a log file every minute "yyyyMMdd-HH-mm"
Example:
_logPrefix = "Logging"
_logDateFormat = "yyyyMMdd-HH"
_logExtension = "log"
Log file created at 23:01 of the 13/01/2019 is: Logging-20190113-23.log
To Log a message include the class in your project and make sure it is in the namespace, being a static class you don't need to instantiate it, just call the method.
You can easily add logging type if the ones included are not enough
Example:
ActivityLog.Info("MAIN FORM", "Application Starting");
ActivityLog.Error("MAIN FORM", "There was an error : " + ex.Message);
ActivityLog.DeleteOldLogs(x) removes the log files older than 'x' days
_retryAttempts is the number retries in case the file is in use
_retryDelay is the number of milliseconds to wait before retry
