Patterns For Logging Diagnostic Messages

Patterns For Logging Diagnostic Messages is a pattern language by Neil Harrison presented in Pattern Languages Of Program Design #3. It's also available under www.cs.wustl.edu . I really like it because I Have This Pattern language. There are 3 patterns:

Diagnostic Logger - create a singleton through which all diagnostic messages are reported. The singleton is used to configure the destination of the messages.

Diagnostic Contexts - add contextual information to diagnostic messages. See Keep Error Information.

Typed Diagnostics - implement a hierarchy of types of diagnostic messages.


'''Three Patterns (Quoted from the paper's Abstract)

The first pattern - Diagnostic Logger

Separates logging from the rest of the software, and lays the groundwork for the other patterns.

The second pattern - Transactional Buckets

Provides association of diagnostics with the correct transactions.

The third pattern - Typed Diagnostics

Helps ensure uniformity of presentation for all diagnostics.


An 'aha!' moment. I was having irritations with my existing logging framework (which used an arbitrary collection of named channels). Reordering it as a hierarchy and handing off requests to the parent channel if undefined has made it all so much more controllable. So I now Have This Pattern 'Typed Diagnostics'. Thanks. -- Frank Carver

Just a passing note: in the program I'm working on presently, I decided to do my logging of both diagnostics and generally-interesting information via a simple Sys Logd client. There was already one written for my environment, but they're very simple to write anyway. Saved me the bother of a bunch of simple but tedious log handling code. But of course this is orthogonal to what you guys are saying. -- Luke Gorrie


I've seen OLTP systems that contain a great deal of concurrency with many users doing their thing at the same time. Part of the logs contain Diagnostic Information, useful in determining the cause of any ills (should they appear). The ability to view logs by user, transaction or real-time interleaved can be very valuable depending on the perspective you're after at the time. With distributed applications this can become even more important as knowing the triggers for various events can key critical. -- Dan Green


log4j (Log For Java) is a free Java package that uses these patterns. -- Nelson Minar

Log For Ruby and Log For Cpp are clones for Ruby Language and Cee Plus Plus, respectively.



See original on c2.com