question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is it possible to get JSON output in the logs? For example, the following log line:

2019-01-10 12:15:07 root:DEBUG thumbor running at 0.0.0.0:8001

… would be awesome to be able to have as:

{
  "timestamp": "2019-01-10 12:15:07",
  "name": "root",
  "level": "DEBUG",
  "message": "thumbor running at 0.0.0.0:8001"
}

I guess I could just tweak the format, but I’d need to escape the message, in case the message would have qoutes in it. Ideas?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
heynemanncommented, Jan 10, 2019

Would be good to have structured logging in thumbor, but I think the best way to go about this is to use thumbor’s own mechanisms for extensibility and allow people to implement their own loggers.

What do I mean by that?

We could change all logging in thumbor to be something like:

logger.debug('Something happened.', image_url=image_url)

Then we’d implement the StdoutLogger that just prints these as:

2019-01-10 12:15:07 Something happened (image_url='/something.jpg')

As well as the JSONLogger, that prints:

{
  "timestamp": "2019-01-10 12:15:07",
  "level": "DEBUG",
  "message": "Something happened",
  "image_url": "/something.jpg"
}

What do you guys think?

0reactions
mbarouskicommented, Jul 7, 2022

@heynemann are there any updates for JSON logging planned?

Read more comments on GitHub >

github_iconTop Results From Across the Web

JSON Logging: What, Why, How, & Tips - Coralogix
The simplicity and flexibility of JSON make it an ideal candidate for generating structured log statements; log data can be extracted and ...
Read more >
8 Essential Tips for JSON logging - Papertrail
8 Essential Tips for JSON logging · Validate Your JSON · Create a Standard Schema · Include a Timestamp in Every Message ·...
Read more >
json-logging - PyPI
Python logging library to emit JSON log that can be easily indexed and searchable by logging infrastructure such as ELK. Go here for...
Read more >
Get Log Output in JSON - Baeldung
Learn how output JSON using the two most popular logging libraries, Jog4j2 and Logback.
Read more >
JSON Logging: 7 Must-Know Tips - Atatus
JSON logging is a type of structured logging in which log data is interpreted and saved in a JSON format. Tips for the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found