LOGGING
Uhm yeh stuff went south with log4j. And some LIBs like JDA uses SLF4J and need a logging backend.
Here is a small guide of how to use the java's own Logging backend java.util.loggin
logging.properties
load file
is a file which specifies on how stuff gets logged, similar to log4j
you have several ways to tell java where this file is:
- default config
I mean obviously ... usually located at
JAVA_HOME/jre/lib/logging.properties
or /PATH_TO_JDK/conf/logging.properties
- use a flag on starting your application
tbh I forgot the flag but ... it's there!
- use the LoggerManager
load your configuration here as example from /main/resources/
LogManager loggerMGlogManager = java.util.logging.LogManager.getLogManager();
loggerMG.logManager.readConfiguration(MissingIDent.class.getClassLoader().getResourceAsStream("logging.properties"));
- Set static JVM Properties
well that possible too but ... again i forgot how to ...
configure
following website helped me to understand what you could configure:
- jenkov.com (general config)
- oracle.com SimpleFormatter (docs for formatting)
- oracle.com Formatter (docs for formatting)
- geeksforgeeks.org (some examples)
I ended up with the following config:
handlers=java.util.logging.FileHandler, java.util.logging.ConsoleHandler
java.util.logging.FileHandler.level=ALL
java.util.logging.FileHandler.limit=10485760
java.util.logging.FileHandler.count=2
java.util.logging.FileHandler.append=true
java.util.logging.FileHandler.pattern=FOOBAABAZ%g.log
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.ConsoleHandler.level=ALL
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.SimpleFormatter.format=[%1$TF-%1$TT][%2$s][%4$s] : %5$s %6$s %n
FOO.BAA.BAZ.level=WARNING