Wouldn’t it be great if I ‘had a central place where I could keep and work on all my little nuggets of utility code I’ve written over the years. Also be able to download them from nuget would be very convenient. This is why I’ve decided to setup a new project on Github. There I just posted the first library of my personal Swiss army knife framework.
These libraries where primarily designed to build loosely-coupled applications where you can swap out particular components without affecting the rest of the application. Most of my libraries are just small layers above existing frameworks providing a common API that simplify their usage (for me at least). The libraries ease the use of these frameworks by providing standard configurations and exposing only the functionalities I found useful for me through what I saw as a “common API”.
The first library I uploaded is: Go.Simple.Logging
GoSimple.Logging is a small and simple library that provides a common interface for logging. It comes together with an implementation for Log4Net: GoSimple.Logging.Log4Net.
It provides a simple logging interface (Logger.Debug(..), Logger.info(..), Logger.warn(…), Logger.Error(…),….). I use this nuget package in all my projects to easily integrate with Log4Netwithout having to remember how to configuer & setup Log4Net.
The library comes with an appender to send the logs through syslog to a Splunk server. The TcpSyslogAppender you’ll find in the Log4Net implementation was extensively tested and fine-tuned on many large scale applications running in production.
You can download it through nugget by using the nugget console:
The most valuable extensions you’ll find in this project are:
- Syslog Appender: used to send your logs over TCP or UDP to a syslog server like Splunk, Logstach or Kiwi.
- Rolling File Appender: when GoSimple rolls a log file, it saves and closes the old file and starts a new file.
GoSimple.Logging comes with a sample project, you’ll find it on the github project home. It provides an example of how to configure your application for GoSimple.Logging in just one line of code. You’ll also find a sample Log4Net config file with example config sections for each appender.
To enable it on your project you need to :
- 1) Review the Log4Net.config file on the application root.
- 2) In VS set the property “Copy to output directory” of the Log4Net.config file to “Copy always”
- 3) In your application entry point (bootstrapper/main) initialize the Logger:
Voilà that’s all you need to configure to enable logging in your application.