2020 m. gegužės 20 d., trečiadienis

Java spring logging


The available logging levels in Logback are:

OFF (output no logs)
ERROR
WARN
INFO
DEBUG
TRACE

Loging messeage meanings:
LOGGER.trace("doStuff needed more information - {}", value);
LOGGER.debug("doStuff needed to debug - {}", value);
LOGGER.info("doStuff took input - {}", value);
LOGGER.warn("doStuff needed to warn - {}", value);
LOGGER.error("doStuff encountered an error with value - {}", value);


To disable dublicating log code to log, add to logback.xml:
additivity="false"


Adding logger like:
private static final Logger log = LoggerFactory.getLogger(YourClassName.class);


Sources: