Skip to content
DreamingLambos edited this page Jan 12, 2019 · 2 revisions

How To Use SimpleLogToFile

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

Where are the Log Files?

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"

What is the Log File Name?

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

How To Log A Message?

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);

How To Clean Up Old Log Files

ActivityLog.DeleteOldLogs(x) removes the log files older than 'x' days

What Are The Other Parameters?

_retryAttempts is the number retries in case the file is in use

_retryDelay is the number of milliseconds to wait before retry

Example Of A Log File

Log File Example

Follow Us

Web

Reddit

TradingView

Twitter

YouTube