Message Log Style Guide

I am looking for a style guide for recording posts:

For instance:

  • What and when
  • Agreement
  • Style and Formatting
  • readability

i.e. what makes a good / bad log message line

I am particularly interested in what makes a good log line — besides including TIME, SEVERITY and COMPONENT, since I usually use log4j, which gives me this information for free.

+4
source share
5 answers

No matter what you decide if it is a text journal, run each line with a good timestamp, preferably in ISO format:

YYYY-MM-DDThh: MM: SS.mmm

In all likelihood, you will need to keep track of the timestamp with a severity code.

Some good logging rules can be found here:

http://watchitlater.com/blog/2009/12/logging-guidelines/

and here

http://download.oracle.com/docs/cd/B32110_01/web.1013/b28952/logging.htm

+1
source

It really depends on your application. I can draw inspiration from anything in / var / log / *

+1
source

Effective logging is an art, but there are a few basic elements that can help:

  • Stream identifier . Enterprise applications often run in a multi-threaded environment. With flow id information, you can distinguish one request from another.

  • Caller ID . The caller ID (or primary) is also an important piece of information. Because different users have different privileges, their execution paths may be different. Including a user ID in log messages can be great help for a security-enabled application.

  • Timestamp . As a rule, users can approximate the time at which the problem occurred. Without a timestamp, it is difficult for support staff to identify a problem.

  • Information about the source code . This includes the class name, method name, and line number.

(These tips are taken from this IBM article on Java registration .)

+1
source

On the side of the agreement, for several years I formatted my magazines as:

severity timestamp source message 

If severity is a symbol for:

 (-) Info (!) Warning (*) Error 

eg:.

 (-) 2010-10-13T18:53:42 foo: Starting up... (!) 2010-10-13T18:54:11 foo: bar: Unable to lock file "quux", will try again in 4 seconds. (-) 2010-10-13T18:56:13 foo: Loading plugin "baz"... (*) 2010-10-13T18:57:39 foo: baz: Error 0xbaadbeef during RPC. (-) 2010-10-13T18:58:04 foo: Shutting down... 

It has become easier for me to look at the search for certain classes of messages (all errors, all warnings), especially when viewing logs using a pager in the terminal.

+1
source

The 10 commandments of journaling is the perfect introduction to the world of journaling.

This website will teach you how to create and not create your own log files.

0
source

All Articles