ScrimpNet.com Developer Utility Library

ScrimpNet.Core.Diagnostics

Logging Quick Start

ScrimpNet logging is designed to make logging easy to use; requires no configuration; and doesn't seriously impact application performance. This sub-system is constantly morphing and forms of it live in a couple Fortune 500 companies, a few mid-sized companies, and many specialized projects for various clients. As we have worked with various projects, we found common frustrations with logging solutions. Thus for our internal projects we began crafting a facade that addresses many of our pain points.

This project is under constant evolution as use-cases are encountered. It is expected that consumers of this library will customize the library so that it fits their needs. We use this library as a foundation for solving routine logging problems...we haven't found a use case where this library addresses all the needs at the engagement and always end up tweaking things.

Logging Feature Summary
• Works out of the box. No configuration is necessary.
• No third-party dependencies. You only need to deploy this library. Nothing more.
• Easy logging calls with enough overloads for many cases
• Asynchronous, thread-safe message writing for high-speed performance
• Rolling file names. Roll on DateTime and/or file size
• Built-in exception expansion including crawling inner exception stack
• Embedded fail-over logic
• End-to-end tracing integration
• Method timing and tracing (if you are not using an AOP provider)
• Lightweight optional configuration
• Integration points with external logging systems
• Based on features of common logging platforms (.Net TraceSource, EntLib, log4Net, NLog)

Getting Started
Getting started is easy. Just try it then you can change it as you see fit.

1. Your project must have a reference to ScrimpNet.Core project. It is recommended you use a project reference instead of binary references where possible. Project references allow you to make changes to the library when you have use-case. They allow for easier debugging should (when) a bug is discovered.

2. Add a reference to ScrimpNet.Core.Diagnostics in your class.

using ScrimpNet.Core.Diagnostics;
3. Create an instance of a logger, usually as a private member variable at the top of your class. For this version, use an instance variable instead of a static member variable for holding your logger reference.

private Log _log = Log.NewLog(typeof(DingoClass));
4. Write log statements. This is all you really need to do generate log messages.

_log.Information("What is this value: {0}", myValue);
_log.Error(badException,"Unable to connect to order: {0}",orderNumber)
NOTE: Remember that by default only Critical, Error, Warning messages are written to log file. To include other levels you must specify them in the .config file.
There are many overloaded logging variants. Don’t let that confuse or frighten you. There are methods to easily log to each of the embedded log levels and each follows a consistent pattern. The overrides are there just to help make it easier to support common use-cases. If you don't like them, or want to add additional functionality, you are free to do so.

Last edited Jan 25, 2011 at 2:41 PM by DrIO, version 5

Comments

No comments yet.