Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java logging framework - with printf() support

In c, printf() is really easy to use, and in Java System.out.printf() is also amazing, but in log4j, seems only can use "First name: "+ firstName +", Age: " + age, which is very uncomfortable.

The questions are:

  • What is the difficulty that prevents log4j from implement such a feature?
  • What logging framework support such feature, can u give a short example that include the maven dependencies & Java code.
like image 803
user218867 Avatar asked Dec 24 '15 16:12

user218867


1 Answers

You can use org.slf4j.Logger which provides a way to format log in such manner.

For example,

LOGGER.info("Roll number of Student {} is {}.", studentName, rollNumber);
like image 72
akash Avatar answered Sep 27 '22 21:09

akash