Skip to content

Simple C# class library for logging to syslog and console

License

Notifications You must be signed in to change notification settings

zhouzu/LoggingModule

 
 

Repository files navigation

SyslogLogging

Simple C# class library for logging to syslog and console. For a sample app please refer to the included test project.

Help or Feedback

First things first - do you need help or have feedback? File an issue here! We'd love to hear from you.

New in v1.3.0

  • Breaking changes
  • Enumerations now part of the namespace and not nested under LoggingModule class
  • Logging to file
  • Configurable maximum message length
  • Configuration exception logging severity (default: alert)

It's Really Easy... I Mean, REALLY Easy

using SyslogLogging;

LoggingModule logging = new LoggingModule("127.0.0.1", 514);
logging.ConsoleEnable = true;
logging.FileLogging = FileLoggingMode.FileWithDate;  // or Disabled, or SingleLogFile
logging.LogFilename = "syslog.txt";

logging.Debug("This is a debug message!");
logging.Exception("Program", "Main", e);

When using FileLoggingMode.FileWithDate, LoggingModule with append .yyyyMMdd to the supplied filename in LogFilename. When using FileLoggingMode.SingleLogFile, the filename is left untouched.

Supported Environments

Tested and works well in Windows in .NET Framework 4.5.2 or later or .NET Core. Tested and works well in Linux and OSX environments, too. Should work well in Mono environments. You may want to use the Mono Ahead-of-time compiler (AOT).

Changing Console Message Color

If you wish to change the colors used by the library, modify the LoggingModule.Colors property. A variable of type ColorScheme exists for each severity level. To disable color manipulation, set this property to null.

log.Colors.Debug = new ColorScheme(ConsoleColor.DarkGray, ConsoleColor.Black);

Version History

Please refer to CHANGELOG.md.

About

Simple C# class library for logging to syslog and console

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%