Location: JWare Software » Log4Ant » Documents » How Tos » Find Logging Provider
Find Logging Provider
Q: How do I find out which logging provider SLF4J is using?
Log4Ant relies on the SLF4J bridge to select the actual logging system that is to be used by your Ant scripts. SLF4J in turn relies on you to explicitly tell it which framework to use by putting your choice in the classpath (in a properly prioritized search order). So for instance, if you want to use LOGBack, you must include the LOGBack SLF4J binder class and configuration in your Ant runtime classpath. Note that you must configure the Ant runtime classpath not the Log4Ant components.
Use <emit:libcheck> to get provider details (maybe)
Log4Ant comes with a “libcheck” task that tries to determine the implementation name and version of the logging system that SLF4J is using. Unfortunately, this mechanism relies on the source vendor having configured a proper set of version information in their jar file’s meta information; sometimes this information is missing or incomplete. To see what Log4Ant can determine about the logging framework in use try:
<target name="about-log4ant"> <emit:libcheck/> <echo message="${slf4j.label}"/> <echo message="${slf4j-impl.label}"/> </target>
Co-existing with Apache Log4J requiring components
If you need to use the Apache Logging For Java (Log4J) framework because of other Ant extensions that require this library, make sure you add the log4j-over-slf4j.jar file from the SLF4J distribution instead of the log4j.jar in your Ant runtime classpath.
Co-existing with Jakarta Commons Logging requiring components
If you need to use the Apache Jakarta Commons Logging (JCL) framework because of other Ant extensions that require this library, make sure you add the jcl-over-slf4j.jar file from the SLF4J distribution instead of the commons-logging.jar in your Ant runtime classpath. Note that you will still need to define and configure your real logging framework because JCL, just like SLF4J, is merely a bridge to a real logging system.
Co-existing with JRE java.util.logging requiring components
If you need to use the standard Java utility logging (JUL) because of other Ant extensions that require this package, you need to tell Log4Ant to explicitly connect the JUL system to the SLF4J system using the <emit:manage> management task. Note using this option will redirect all JUL logging to SLF4J so you do not need to configure JUL. However, you should understand how SLF4J will map the various JUL log records into its own data; read the SLF4J JUL Bridge Handler documentation.
<emit:manage action="install-jul2slf4j"/>