LoggingHelper

Library for easy logging.


Keywords
eventlog, log, logfiles, logger, loggin, tracing
License
MIT
Install
Install-Package LoggingHelper -Version 1.2.0

Documentation

NuGet

Veja a documentação em português clicando aqui.

LoggingHelper

Library for easy logging.


AVAILABLE FEATURES:

✔ Allows logging with different levels of severity;
✔ Use the Write method to write logs to the file;
✔ Use the LevelStack property to define the maximum level to be considered in the method stack;
✔ The LogValidity property allows defining the maximum time (in days) for the log file to be reset;
✔ LogLevel represents the minimum level of log to be recorded in the file;
✔ The LogPath property define the location and file where the log should be recorded;
✔ Use the Check method to perform all validations before writing the log;
✔ GetCallingMethodName allows to identify who called considering stack level;
✔ Old logs can be automatically deleted through the initial check method (Check);
✔ More features coming soon.



INSTALLATION:

 dotnet add package LoggingHelper --version 1.1.0



EXAMPLE OF USE

Code:

using LH;

namespace App
{
    static class Program
    {
        static void Main()
        {
            try
            {                
                LoggingHelper.Write("This is a trace log message.", 0, "Start application.");
                LoggingHelper.Write("Debug message.", 1, null);
                LoggingHelper.Write("This is a message for an information log.", 2, null);             
                LoggingHelper.Write("This is also a message for an information log.", LoggingHelper.Level.INFO, null); 
            }
            catch (Exception ex)
            {
                LoggingHelper.Write("This is a log message for logging errors!", 4, ex.Message);
            }            
        }
    }
}

Result:

20/08/2023 14:06:56 [TRACE] (/Main) This is a trace log message. | Start application.
20/08/2023 14:06:56 [DEBUG] (/Main) Debug message.
20/08/2023 14:06:56 [INFO] (/Main) This is a message for an information log.
20/08/2023 14:06:56 [INFO] (/Main) This is also a message for an information log.
20/08/2023 14:06:56 [ERROR] (/Main) This is a log message for logging errors! | Exception of type 'System.Exception' was thrown.