Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Log message style guide

I'm looking for a style guide to log messages:

For example:

  • What & when
  • Conventions
  • Style & Formatting
  • Readability

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

I'm particularly interested in what make a good log string - beyond including the TIME, SEVERITY and COMPONENT, as I tend to use log4j which gives me this information for free.

like image 397
Joel Avatar asked Oct 13 '10 16:10

Joel


People also ask

What is a log message?

In computing, a log file is a file that records either events that occur in an operating system or other software runs, or messages between different users of communication software. Logging is the act of keeping a log. In the simplest case, messages are written to a single log file.


2 Answers

Whatever you decide, if it's a text log, start each line with a good timestamp in, preferably, ISO format:

YYYY-MM-DDTHH:MM:SS.mmm

In all likelihood, you will want to follow the timestamp with a severity code.

Some good logging guidelines 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

like image 77
Michael Goldshteyn Avatar answered Oct 12 '22 03:10

Michael Goldshteyn


That really depends on your application. I may draw inspiration from anything at /var/log/*

like image 24
liorda Avatar answered Oct 12 '22 03:10

liorda