SLF4J NoSuchMethodError on LocationAwareLogger

The javadocs for NoSuchMethodError say, Normally, this error is caught by the compiler; this error can only occur at run time if the definition of a class has incompatibly changed. So this is probably being caused by incompatible versions of slf4j being loaded. Rather than looking at your classpath and guessing where classes are loaded, … Read more

slf4j logging with jdk – how to enable debug?

Why do you think it does not log DEBUG messages? If you mean that your log.debug(String) logging calls do not end up in java.util.logging log files, then I guess you have to configure the logging.properties configuration file to allow log messages at FINE level. If you do not want to mess with the global %JRE_HOME%/lib/logging.properties, … Read more

How to enable DEBUG level logging with Jetty embedded?

My question was answered on the Jetty mailing list by Joakim Erdfelt: You are looking at the old Jetty 6.x docs at docs.codehaus.org. DEBUG logging is just a logging level determined by the logging implementation you choose to use. If you use slf4j, then use slf4j’s docs for configuring logging level. http://slf4j.org/manual.html If you use … Read more

Using java annotation to inject logger dependency

You can use the BeanPostProcessor interface, which is called by the ApplicationContext for all created beans, so you have the chance to fill the appropriate properties. I created a simple implementation, which does that: import java.lang.reflect.Field; import java.util.List; import net.vidageek.mirror.dsl.Mirror; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeansException; import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.stereotype.Component; @Component public class LoggerPostProcessor implements … Read more

Force slf4j to use logback

Generally your own code is at the beginning of the classpath. Because of this, one way to do it is to create your own org.slf4j.impl.StaticLoggerBinder class: package org.slf4j.impl; import org.slf4j.ILoggerFactory; import org.slf4j.spi.LoggerFactoryBinder; /** * Force tests to use JDK14 for logging. */ @SuppressWarnings(“UnusedDeclaration”) public class StaticLoggerBinder implements LoggerFactoryBinder { private static final StaticLoggerBinder SINGLETON = … Read more

Send/redirect/route java.util.logging.Logger (JUL) to Logback using SLF4J?

It’s very easy and not a performance issue anymore. There are two ways documented in the SLF4J manual. There are also precise examples in the Javadocs Add jul-to-slf4j.jar to your classpath. Or through maven dependency: <dependency> <groupId>org.slf4j</groupId> <artifactId>jul-to-slf4j</artifactId> <version>1.7.0</version> </dependency> If you don’t have logging.properties (for java.util.logging), add this to your bootstrap code: SLF4JBridgeHandler.removeHandlersForRootLogger(); SLF4JBridgeHandler.install(); … Read more

LoggerFactory.getLogger(ClassName.class) vs LoggerFactory.getLogger(this.getClass().getName())

Late entry! As I am likely to be searching for this in the future. There is a way to create copy/paste friendly Logger instances (granted this is almost never a good reason to do something!) by using Java 7’s MethodHandles class. private static final Logger LOGGER = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());

How to get liquibase to log using slf4j?

There is, but it is a little bit obscure. Quoting Fixing liquibase logging with SLF4J and Log4J: There’s The Easy Way, by dropping in a dependency: <!– your own standard logging dependencies –> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.7.5</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId><!– or log4j2 or logback or whatever–> <version>1.7.5</version> </dependency> <!– special dependency to fix liquibase’s … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)