SLF4J usage
Using SLF4J in a java project
SLF4J is the most straightforward logging framework to I’ve used for java apps. I found these instructions from stackify.com pretty useful.
If you have a simple spring boot app, these are all the steps you need to follow:
...
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
...
class SchedulerServiceTest {
Logger logger = LoggerFactory.getLogger(SchedulerServiceTest.class);
...
The actual logging lines look like so:
logger.info("testing date and hour {} {}",date,i);
where you can pick methods debug()
, info()
, warn()
, error()
depending on your need. You may also use the {} syntax to substitute values from variables.