1h Spring Boot Logging Crash Course For Beginners (Config, Remote Logs, JSON Logging & More)

preview_player
Показать описание
In this video you'll learn everything you need to know about logging the right way on Spring Boot. This crash course will be split into these parts:

Console logging
Changing default logger config (+ log setup for dev & prod)
Remote logging with Grafana Loki
Rotating JSON file logs

Afterwards, you'll be able to know what to log where and how to set up your rules to only see what you need to see.

⭐ Courses with real-life practices
⭐ Save countless hours of time
⭐ 100% money back guarantee for 30 days
⭐ Become a professional Android developer now:

🎓 Become an industry-ready Android developer in the Mobile Dev Campus:

🎁 Get my FREE 4.5h Best Practice Guide to Android Architecture:

💻 Let me be your mentor and become an industry-ready Android developer in 10 weeks:

Regular programming advice on my Instagram page:

Get the source code for this video on GitHub:

📺 Full 2025 Backend Dev Crash Course for Beginners With Spring Boot (Kotlin, JWT Auth, MongoDB)

00:00 - Introduction
2:00 - Console logging
7:05 - Configuring what to log when
13:14 - Grafana Loki overview
16:24 - Console logger config with Logback
24:10 - Grafana Loki log appenders
44:20 - Attaching custom Loki metadata
53:46 - Rotating JSON file logs
1:01:17 - Production logging best practices
Рекомендации по теме
Комментарии
Автор

Thanks a lot Philipp, simple, easy and clever!

bmxbmx
Автор

Hey Philipp, I noticed that there are sometimes logs (uncaught exceptions) in a .err.log file. How can I configure the log format for that file? BTW - thank you for this; I have always found the logging configuration to be a bit opaque.

caetzar
Автор

@Phillipp Lackner, I have been a subscriber and followers of yours for the last 4 years. I kindly request you to create some videos on AI specifically for Android developers. AI has a vast amount of concepts to learn, and as an Android developer, I'm unsure of where to start. Could you please provide some guidance and a learning path for AI in the context of Android development? I am requesting this once more and would greatly appreciate your help.

abhishektripathi
Автор

Few comments here:
- never ever format logs as json, it is absolutely unmanageable! Even in the video, in logs drilldown, all those log statements are just unreadable mess
- there are standard conventions for labels, for example service_name, not "app" or "service"; same goes to trace_id
- labels shouldn't be hardcoded in config, they should be dynamic - whole MDC should go there
- you shouldn't be logging via loki protocol, it needs to be otel
- and all that config shouldn't be manual, everything is already automated by opentelemetry
- MDC.clear is a bug, needs to be putCloseable
- with slf4j you should be leveraging structured logging, not rather useless static strings
- please do not structure spring boot apps like this

TheDeilux
welcome to shbcf.ru