Logging Services


I've found it helpful to think of logging as a service provided to the development team that abstracts the complexity of implementing good logs. The actual implementation of a logging service varies from architecture to architecture, but in most cases it can be some form of Singleton. Implementing the log file as a centralized service has the following advantages.

  • Internationalization: Within the source code you can invoke the logging service with an identifier associated with a given log entry, passing in any additional data as necessary. The logging service can use this identifier to look up any internationalization of the log entry and write these data to the log file.

  • Unified time ordering: Logging requests in multi-threaded applications can appear to occur out of order because of slight differences in thread execution. A logging service can help make certain that log requests are written to the log file in a sensible manner. In addition, because only one component has generated timestamps, chances are further reduced that log entries will appear out of order.

  • Flexible destinations: The logging service can choose the destination(s) of log entries at run-time via configuration files. This allows developers to concentrate on what should be logged and allows operations personnel to choose where it should be logged.

  • Consolidation across multiple instances or servers: If you're operating in an environment in which multiple instances of your application are running on one or more servers, consider augmenting log file names or contents with additional information that allows you to disambiguate various data. Examples of such data include the process or thread ID and the IP address of the host machine.



Beyond Software Architecture[c] Creating and Sustaining Winning Solutions
Beyond Software Architecture[c] Creating and Sustaining Winning Solutions
ISBN: 201775948
EAN: N/A
Year: 2005
Pages: 202

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net