0

I inherited a project that is not in Maven & has no documentation on dependency set up. I'm getting A LOT of errors related to slf4j.

For example, the _logger.error() call in the following code generates this compile error: "The method error(String, Object, Object) in the type Logger is not applicable for the arguments".

import org.slf4j.Logger; 
import org.slf4j.LoggerFactory;

//lines ommitted

Logger _logger; 

//lines ommitted
    _logger.error("getValueList|Error|valueId|{}|date|{}| current|{}|", _valueId, _date,_current);

What slf4j jars do I need to include in my class path to avoid this? Note, I already have all of slf4j 1.7.5 in my classpath & most logging statements compile fine, but others do not. I'm not sure how to fix this.

UPDATE - added extra code for clarity

6
  • Well ... What type does _logger have? Commented May 19, 2016 at 16:42
  • @Seelenvirtuose I would imagine it has type Logger judging by the compile error Commented May 19, 2016 at 16:48
  • Logger _logger; With import org.slf4j.Logger; & import org.slf4j.LoggerFactory; as imports Commented May 19, 2016 at 16:51
  • @jthomas There are so many logging frameworks with even more Logger types. Look at OP's answer for my question. He uses org.slf4j.Logger. Commented May 19, 2016 at 16:56
  • Are you sure the 3 additional parameters are Objects and not for instance int or long? Commented May 19, 2016 at 17:07

2 Answers 2

1

SOLVED: I accidently included slf4j-api-1.6.6.jar in the classpath. That was being linked instead of slf4j-api-1.7.5.jar. Once I removed slf4j-api-1.6.6.jar the slf44 compile errors went away.

thanks for your help.

Sign up to request clarification or add additional context in comments.

Comments

0

Just refer to this link http://www.slf4j.org/apidocs/org/slf4j/Logger.html As per the doc, there is no way to include 3 arguments in the logger.error method the way your code is doing. The only way to involve more than two Objects for logging is by putting those objects in an array and passing it as parameter to the logger.error method

Refer to

void error(String format, Object... arguments)

method on the page

2 Comments

The varargs works also when passing comma separated parameters
See my answer. I think varargs was added in 1.7.x. Therefor my mistaken addition of 1.6.6 to the classpath caused the issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.