Skip to content
This repository was archived by the owner on Jul 23, 2024. It is now read-only.

This is a simple csv file logger for logging errors in a c# application.

License

Notifications You must be signed in to change notification settings

kolappannathan/simple-csv-logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

88 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple CSV Logger

The repository is archived for reference. The package is no longer maintained.

Targets .Net standard 2.0 GitHub

This is a simple logger for logging errors in a c# application. But instead of writing the logs to a txt file this logger writes them into a CSV file.

Downloads: Nuget

Usage

  1. Install the nuget package.
  2. Create an instance for nk.logger.csv.Logger in your base class.
  3. Edit the configuration according to your application needs.
  4. Create wrapper functions for the functions you need from csv.logger.
  5. Inherit this base class in your other classes.

Example

Below is a sample base class with configurations,

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();
            
            // adding configuration
            config.SetDateTimeFormat(dateFormat)
                .SetFileName(fileName)
                .SetRelativePath(relativePath)
                .SetReplacementValue(replacementValue);
            
            csvLogger = new nk.logger.csv.Logger(config);
        }

        #region [Public Logger functions]

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

        #endregion [Public Logger functions]
    }
}

About

This is a simple csv file logger for logging errors in a c# application.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages