Java Logging statement says character cannot be found

private static final Logger LOGGER = LoggerFactory.getLogger(Updater.class); 

I use SLF4J and Logback

When I try to record statements

 LOGGER.info("{}:{}:{}", one, two, three) 

it says

 cannot find symbol method info(java.lang.String,java.lang.String,java.lang.String,java.lang.String) 

Is there no way to write more than two variables in one info statement?

+4
source share
3 answers

You must upgrade SLF4J to 1.7, which includes the Logger.info(java.lang.String, java.lang.Object...) varargs method. See Error 31 - Vargars for Logger methods fixed after discussion for six years.

Prior to version 1.7, you must surround arguments with Object[] if you use more than two:

 LOGGER.info("{}:{}:{}", new Object[] {one, two, three}) 

see also

+9
source

Perhaps you are using an older version of slf4j.

In the previous version, you could register up to 2 parameters this way, but the newer version can accept any number of parameters .

+1
source

According to the JavaDoc in Logger, you can use any of the following:

  void info(String format, Object... arguments) void info(String format, Object arg) void info(String format, Object arg1, Object arg2) 
0
source

Source: https://habr.com/ru/post/1440648/


All Articles