Taming Java logging dependencies

Pubblicato il: 16 febbraio 2025
sul canale di: coderbin
23
1

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/tamin...

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


In questa pagina del sito puoi guardare il video online Taming Java logging dependencies della durata di online in buona qualità , che l'utente ha caricato coderbin 16 febbraio 2025, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 23 volte e gli è piaciuto 1 spettatori. Buona visione!