Connected via dependency SLF4j-api and Logback. Inside the class I write

private static final Logger log = LoggerFactory.getLogger(Printer.class); 

then there is a method

 public static void collectionPrint(ArrayList list) { Iterator iterator = list.iterator(); while (iterator.hasNext()) { log.info("Printer ",iterator.next()); } } 

It should display the collection, through System.out.println it displays everything correctly.
And in the logger writes

20: 57: 02.527 [main] INFO com.epam.as.coffeevan.service.BeverageFinder - Printer

How can this be fixed?

    1 answer 1

    The first parameter of the logging methods in SLF4J is the string pattern . You must use the {} macro in places where you want to perform substitution. For example:

     logger.debug("Result={}, time={}", result, time); 

    Accordingly, in your case it will be:

     log.info("Printer {}", iterator.next()); 

    Be sure to read the FAQ about parameterized logging .

    • Damn, I knew it) just forgot) thank you! - D.Mark