Member-only story

Structured Logging , Why and how to achieve in java.

krishankant singhal
3 min readFeb 16, 2020

--

Logs are important piece of information for an applications . It helps us to find out issues in dev/qc/Production . help us in detecting anomalies , to do real-time analytics and lot of others things.

Generally a simple hello world java logs look like this

10:03:35.331 [main] INFO com.learnlog.MyLooging - Hello World

This log is having timing, thread , log level, package name and message.

but it is in a single line. and now assume thousands of logs like that. so it is difficult to read and understand.

This kind of logs are called Unstructured logs. and doing any kind analytics , searching on various fields etc is difficult. For example if i want to search logs on basics of package com.learnlog.MyLogging. and there are billions of logs from multiple system and multiple packages. log aggregator has to go through all these lines ,index them and process.

but if make these log structured , above hello word logs might look like this

{
"timestamp" : "2020-02-16T15:16:32.485Z",
"level" : "INFO",
"thread" : "main",
"logger" : "com.learnlog.MyLooging",
"message" : "Hello World",
"context" : "default"
}

--

--

krishankant singhal
krishankant singhal

Written by krishankant singhal

Angular,Vuejs,Android,Java,Git developer. i am nerd who want to learn new technologies, goes in depth.

Responses (2)