Geeks With Blogs
cType(YourBrain, MyBrain) ... DirectCast threw an exception.

I’ve been playing around with the nSpring logging package for one of my latest projects. Impressing me most has been the virtual non-impact on performance. The current bits are here.

Features from CodeProject article:

High performance: Classes Debug and Trace are slow; unbuffered use of these classes can entail a significant performance degradation in application code. Loggers in this framework provide buffering ability (asynchronous output) as well as other caching features; this results in ~500 nanosecond per-message log times on a P4-M 2.0GHz laptop. Further performance optimizations are planned for later releases.

Stability: Every class in the logging package is thread-safe and performance-tuned for use in a multithreaded environment. Also, logging-failure support can be provided via classes implementing the ExceptionHandler interface; since the Logger base class itself implements this interface, all loggers can provide failover logging support for each other.

Ease of use: Loggers provided in this package are easy to understand and to use. Each one represents a different form of output; many different pre-written loggers are provided, covering everything from email logging to database logging to various forms of file-based logging, and most of them can be easily configured by calls to their constructor methods. Care has been taken to make each interface as intuitively easy-to-use as possible.

Ease of extension: Users can define their own loggers, filters, exception handlers, event formatters, data formatters, and log levels with ease, usually by just instantiating an object or implementing one or two methods. For instance, a custom Logger subclass can be created by implementing just a single method and still gain all the benefits of the Logger class, including buffering support.

Levels: Each log message (Event) is accompanied by a "priority" level. Each Logger has an associated level, and discards all events lower than this default level, providing simple yet fine-grained message-filtering ability. Users can also define their own levels, as long as they contain unique information.

Flexible filtering: A hallmark of good logging support is the ability to selectively discard logged data based on more in-depth criteria than can be provided by the use of levels. Not only are many prebuilt filters provided in the NSpring.Logging.Filters namespace, but it's easy to implement custom filters by subclassing the Filter class.

Flexible formatting: Useful types of log-record formatting are supplied via the classes in the NSpring.Logging.EventFormatters namespace. The XMLEventFormatter is highly configurable, and users can also supply their own formatting logic by subclassing the EventFormatter class. A simple formatting language also provides a great deal in formatting flexibility.

Data support: Each log event can carry an object data "payload". Support is built in for correct output of all arrays, lists and dictionary classes, together with the ability to supply format strings for each primitive type, as well as such structures as DateTime and TimeSpan. Users can extend the data formatting abilities of loggers by subclassing DataFormatter. Three types of data-formatting implementations are provided out-of-the-box.

Partitioned access: Debug and Trace provide only two points of global access to logging facilities in your applications. This can be bad for many reasons, not least of which is that the default ways of segregating content (the Indent() and Unindent() static methods) were provided without any thought of multithreaded use. In other words, two threads attempting simultaneous use of Debug and Trace can interfere with each other. Also, while you can create various listeners for these two classes, the classes must implement their own filtering logic (entailing a worst-case exponential performance slowdown with each listener added) because all output is funneled through either Debug or Trace. This leads to the next point.

Naming: Loggers can be registered with one or more names using a LoggerRegistry object. The Logger class itself provides global named access to loggers by use of an internal static default LoggerRegistry.

Composition: Loggers in this framework can be added to each other as children, receiving hand-me-down events. Different logging structures can be created for different needs, all organized under one easy-to-use name. Filters can also be composed of other filters using the CompositeFilter class.

Event categorization: Debug and Trace provide only four possible data fields for each logged event: a string message, a more-detailed string message, a string category, and an object data payload. There are no provisions made for different applications/modules logging using the same logging subsystem, etc. Each Event object logged by the NSpring logging framework contains fields for timestamp, text message, data object, event category, event code, event ID, event severity level, application name, and system name. Many different variations on the Logger class' Log method are provided to make these easy to use, and log filters (via the Filter class and its children) are provided that work with each of the fields. Certain loggers (such as FileLogger and MessageQueueLogger) have the ability to "scatter" output to many different files, queues, etc. based on the properties of the events logged through them. The ability to send output to different named loggers also provides a useful degree of categorization ability.

Support for existing code: The logging package may be used with existing code that depends on Debug and Trace by use of the DebugLogger and TraceLogger classes; by using logger composition, the same output can easily be redirected through other forms of output as well. (Also in the works: a series of event-source classes that can listen to a variety of data sources, including Debug and Trace, and pipe the resulting data through logging classes.)

[From CodeProject]

Posted on Thursday, February 2, 2006 10:12 AM | Back to top

Comments on this post: nSpring OpenSource Logging Package

# re: nSpring OpenSource Logging Package
Requesting Gravatar...
I discovered your online journal utilizing man. This is an extremely elegantly composed article. I"ll make sure to bookmark it and return to peruse a greater amount of your valuable data. A debt of gratitude is in order for the post. I"ll certainly return.
local plumbing companies available
Left by Mike on Mar 15, 2017 11:29 AM

Your comment:
 (will show your gravatar)

Copyright © Hal Lesesne | Powered by: