Do you know a set of guidelines for writing into a log file?

The file can be long, it should contain a log message per line, including dates and system feedback / audit actions. I may contain user names, status messages, ERRORs, references to files or applications, etc. Each line should not be so long, but there could be exceptions. We cannot use colors, font formatting (like bold or italic) or GUI.

The purpose is to make it more readable and to help the reader to visually scan and find important information easily.

Hint: the user may be a system admin / technical user and it's on Linux environment. Information about well-known characters and words is also valid.

  • 1
    related blog post the-10-commandments-of-logging
    – Ricardo
    Commented Feb 28, 2017 at 21:05
  • examples of guidelines @ is-ok-nok-better-than-fail-success?
    – Ricardo
    Commented Feb 28, 2017 at 21:06
  • How long your log files will be? That is, on average, how many lines (line-breaks / entries)?
    – Izhaki
    Commented Feb 28, 2017 at 22:04
  • Let's assume it's possibly very long.
    – Ricardo
    Commented Mar 1, 2017 at 2:56
  • Do you need to make it very technical? Are you designing a more friendly logging system? Commented Mar 1, 2017 at 14:36

1 Answer 1


One important thing about plaintext formatting is lining up columns. If you have values of a predictable maximum size like numbers that will never be more than 9 digits, or dates and times you should pad with extra space so they are inside a column of uniform width to aid visual scanning.

Currency values usually hav a standard .00 at the end and is right aligned in it's column.

Consider using commas to separate thousands if you know the locale of your audience. European countries flip the meaning of commas and periods in number formatting sometimes.

Put the columns with fixed widths to the front and those with variable widths at the end. Then sort by importance to the audience, (usually someone that is trying to troubleshoot a problem).

Put dates in the standard order of increasing granularity "2017-03-01" that way it sorts visually.

Using Pipe characters to delimit fields should be considered unless there is a pressing need for a more standard delimiter such as a comma.

Add visual padding using spaces around each delimiter

Avoid visual clutter such as string quotes around values.

Consider using emoji if you think this will be in a Unicode text buffer. But don't go overboard with the emoji. A restrained vocabulary is best since meanings are so subjective, and subjectivity is usually not desirable in a log file.

Here's my mockup:

| 2017-03-01 |    12.33 |     | Foo       | Bar.bat.alice.bob.variablelengthstrings | lorem ipsum dolor sit amet something something
| 2017-03-02 |   824.01 |   | FooBarBat | bob.variablelengthstrings | lorem ipsum something
| 2017-03-02 | 1,223.11 | | Foo       | variablelengthstrings | lorem ipsum dolor sit amet another thing that goes long something something

Do a technical test run of whatever you come up with by importing a sample log file into Excel and see what happens.

  • You've captured valuable concepts here. Thanks. It's important to notice that we can't always sort the results, specially for real-time logging.
    – Ricardo
    Commented Mar 3, 2017 at 18:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.