O'Reilly logo

Java Persistence with MyBatis 3 by K. Siva Prasad Reddy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Customizing MyBatis logging

MyBatis uses its internal LoggerFactory as a facade to actual logging libraries. The internal LoggerFactory will delegate the logging task to one of the following actual logger implementations, with the priority decreasing from top to bottom in the given order:

  • SLF4J
  • Apache Commons Logging
  • Log4j 2
  • Log4j
  • JDK logging

If MyBatis finds none of the previous implementations, logging will be disabled.

If your application is running in an environment where multiple logging libraries are available in its classpath and you want MyBatis to use a specific logging implementation, you can do this by calling one of the following methods:

  • org.apache.ibatis.logging.LogFactory.useSlf4jLogging();
  • org.apache.ibatis.logging.LogFactory.useLog4JLogging(); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required