CSV Logger

This is a C# logger class which logs error and other debug info into CSV files instead of a traditional text files. The logger also contains 6 levels of logging and log from text messages as well as exceptions.
Download Via

Usage

  1. Install the nuget package.
  2. Create a csvlogger instance in your base class.
  3. Pass the filename, datetime, relative path and other parameters according to your application.
  4. Create wrapper functions for the functions you need from csv.logger.
  5. Inherit this base class in your other classes.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using System;

namespace Core.Lib
{
    public class Logger
    {
        private nk.logger.csv.Logger csvLogger;

        public Logger(string dateFormat, string fileName, string relativePath = "", char replacementValue = ';')
        {
            var config = new nk.logger.csv.LoggerConfig();
            config.SetDateTimeFormat(dateFormat)
                .SetFileName(fileName)
                .SetRelativePath(relativePath)
                .SetReplacementValue(replacementValue);
            
            csvLogger = new nk.logger.csv.Logger(config);
        }

        // Logger functions for using within your app
        public void Error(Exception ex) => csvLogger.Error(ex);
        public void Fatal(Exception ex) => csvLogger.Fatal(ex);
        public void Debug(string text) => csvLogger.Debug(text);
        public void Error(string text) => csvLogger.Error(text);
        public void Fatal(string text) => csvLogger.Fatal(text);
    }
}

Disclaimer

These software is provided on a AS IS basis. No warranty is provided with this software. Make sure to backup your data before using this software.