Загрузка...

Taming Java logging dependencies

Ever got confused about how to deal with logging dependencies in Java? There is slf4j, logback, log4j, java-util-logging, and different rules for applications vs libraries. This video goes through in painful detail the best practices on how to configure dependencies for all different scenarios.

Source code for this video is at https://github.com/coderbin-dev/taming-java-logging

The rules
---------

* The only **compile** time dependency should be `slf4j-api`
* For libraries: only add test-scoped dependencies on something like `slf4-simple`
* For apps: add a runtime dependency on the logging framework with config.
* For libraries: no config should be included in the dependency!!
* If any dependencies use `java.util.logging` then use `jul-to-slf4j`
* Exclude logging frameworks from misconfigured dependencies

00:00 Introduction
00:20 Setting up a demo app with console logs
00:58 Setting up log4j
02:54 Introducing a dependency
06:35 Setting up logback
08:29 Introducing SLF4J
11:00 Fixing multiple implementations problem
12:40 sl4fj-simple in tests
14:15 Logging to files
15:42 Seperate test logging config
17:15 The rules
17:57 Dealing with java.util.logging
20:16 Excluding bad dependencies
21:15 Summary

Видео Taming Java logging dependencies канала coderbin
Яндекс.Метрика

На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.

Об использовании CookiesПринять