开发者

Help recognizing this logger

开发者 https://www.devze.com 2023-03-26 19:48 出处:网络
guys I\'m trying to correct an application... where I found this lines of code: private static final Log log=LogFactory.getLog(MyClass.class);

guys I'm trying to correct an application... where I found this lines of code:

private static final Log log=LogFactory.getLog(MyClass.class);

then this logger is used like this:

log.info("The message has the following arguments {0},{1},{2}",arg1.toString(),arg2.toString(),arg3.toString());

Of course this is giving me compile err开发者_如何学Pythonors. The problem is that they have a similar pattern in several classes, where there is the same error.

The imports of the log classes are:

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

Are these ones correct??, or I should use another imports like, Log4j or Slf4j.

Thanks a lot.


EDIT : I think the specific syntax you are referring to is falling on SLF4J lines. check the example in http://www.slf4j.org/apidocs/org/slf4j/Logger.html. Then the imports will change accordingly.

They are correct. Refer http://commons.apache.org/logging/guide.html

If you are on maven.

use this to resolve your compilation errors

<!-- Apache commons-logging --> 
    <dependency> 
      <groupId>commons-logging</groupId> 
      <artifactId>commons-logging</artifactId> 
     <version>1.1.1</version> 
   </dependency> 
0

精彩评论

暂无评论...
验证码 换一张
取 消