Better Programming

Advice for programmers.

Follow publication

The Art of Logging

Jaouher Kharrat
Better Programming
Published in
7 min readSep 17, 2022
Photo by Viktor Talashuk on Unsplash

Why Should Logs Be Human Readable?

Photo by Elisa Ventur on Unsplash
66.249.65.159 - - [06/Nov/2014:19:10:38 +0000] "GET /news/53f8d72920ba2744fe873ebc.html HTTP/1.1" 404 177 "-" "Debian APT-HTTP/1.3 (0.8.16~exp12ubuntu10.16)"
{
"time": "06/May/2022:19:10:38 +0100",
"remote_ip": "66.249.65.159",
"remote_user": "-",
"request": "GET /news/53f8d72920ba2744fe873ebc.html HTTP/1.1",
"response": 404,
"bytes": 177,
"referrer": "-",
"agent": "Debian APT-HTTP/1.3 (0.8.16~exp12ubuntu10.16)"
}

Why Should Logs Be Machine Friendly?

66.249.65.159 - - [06/Nov/2014:19:10:38 +0000] "GET /news/53f8d72920ba2744fe873ebc.html HTTP/1.1" 404 177 "-" "Debian APT-HTTP/1.3 (0.8.16~exp12ubuntu10.16)"
Photo by Alex Knight on Unsplash

Which Information To Include?

Log Levels and Associated Log Codes

The Proposed Format

Sample message generated using carbon

Observations

Best Practices

Final Notes

Acknowledgment

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Jaouher Kharrat
Jaouher Kharrat

Written by Jaouher Kharrat

Engineering Manager & Software Engineer | Hardcore Gamer | JS, PHP, GO | IAM adept | Packtpub author | @EQS Group | http://github.com/JaouherK

Responses (6)

Write a response