Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What to write into log file?

My question is simple: what to write into a log. Are there any conventions? What do I have to put in?

Since my app has to be released, I'd like to have friendly logs, which could be read by most people without asking what it is.

I already have some ideas, like a timestamp, a unique identifier for each function/method, etc.. I'd like to have several log levels, like tracing/debugging, informations, errors/warnings.

Do you use some pre-formatted log resources?

Thank you

like image 390
Boris Guéry Avatar asked Apr 23 '09 01:04

Boris Guéry


People also ask

What format should a log file be?

The JSON (JavaScript Object Notation) is a highly readable data-interchange format that has established itself as the standard format for structured logging. It is compact and lightweight, and simple to read and write for humans and machines.

What does a log file tell you?

Logs files are a historical record of everything and anything that happens within a system, including events such as transactions, errors and intrusions. That data can be transmitted in different ways and can be in both structured, semi-structured and unstructured format.


1 Answers

It's quite pleasant, and already implemented.

Read this: http://docs.python.org/library/logging.html


Edit

"easy to parse, read," are generally contradictory features. English -- easy to read, hard to parse. XML -- easy to parse, hard to read. There is no format that achieves easy-to-read and easy-to-parse. Some log formats are "not horrible to read and not impossible to parse".

Some folks create multiple handlers so that one log has several formats: a summary for people to read and an XML version for automated parsing.

like image 155
S.Lott Avatar answered Nov 09 '22 10:11

S.Lott