简体   繁体   中英

SLF4J logging interface with JDK Logger

I using slf4j logging interface with JDK logger for my web service project. I have been actually using Java util logging and currently thinking of move to using slf4j with JDK logger. I have included slf4j-jdk14-1.7.12 jar file dependency in my ivy.xml file

In one of my classes, I have the following:

  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
 public class Example{
   public static Logger logger = LoggerFactory.getLogger(Example.class);

   public void sampleMethod() {

     logger.info("Logging this method");
}
}

After running this class/method, I dont see any log output to either the console or to any log file. Currently the java util logging framework under use, write the logs to a file. I looked in that folder to check to see if any log files related to this class was created, but none.

Can you please help me to identify why this is not working. I read online about configuring the logging.properties. I am not sure how to do that, where to place the properties file?

Thanks in advance.

Based on your description you are looking to migrate to SLF4j with java.util.logging as an implementation. For that you'll need to provide SLF4j bridge jars for log4j and jcl over SLF4j which most likely is the reason why you don't see any output.

In other words according to this very nice descriptive depiction you'll need to follow this approach:

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM