forked from phoedos/pmd
[core] Add jul-to-slf4j bridge
This is at least needed for apex jorje, but might be handy for any other library that logs through jul.
This commit is contained in:
parent
d1cc05e4d5
commit
7b702bd6eb
@ -79,6 +79,10 @@
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jul-to-slf4j</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.antlr</groupId>
|
||||
<artifactId>antlr4-runtime</artifactId>
|
||||
|
@ -544,6 +544,7 @@ public final class PMD {
|
||||
|
||||
final Level logLevel = configuration.isDebug() ? Level.DEBUG : Level.INFO;
|
||||
Slf4jSimpleConfiguration.reconfigureDefaultLogLevel(logLevel);
|
||||
Slf4jSimpleConfiguration.installJulBridge();
|
||||
// need to reload the logger with the new configuration
|
||||
log = LoggerFactory.getLogger(PMD.class);
|
||||
log.atLevel(logLevel).log("Loglevel is at {}", logLevel);
|
||||
|
@ -32,6 +32,7 @@ import net.sourceforge.pmd.RuleSetLoader;
|
||||
import net.sourceforge.pmd.ant.Formatter;
|
||||
import net.sourceforge.pmd.ant.PMDTask;
|
||||
import net.sourceforge.pmd.ant.SourceLanguage;
|
||||
import net.sourceforge.pmd.internal.Slf4jSimpleConfiguration;
|
||||
import net.sourceforge.pmd.lang.Language;
|
||||
import net.sourceforge.pmd.lang.LanguageRegistry;
|
||||
import net.sourceforge.pmd.lang.LanguageVersion;
|
||||
@ -241,6 +242,7 @@ public class PMDTaskImpl {
|
||||
|
||||
public void execute() throws BuildException {
|
||||
Level level = Slf4jSimpleConfigurationForAnt.reconfigureLoggingForAnt(project);
|
||||
Slf4jSimpleConfiguration.installJulBridge();
|
||||
// need to reload the logger with the new configuration
|
||||
Logger log = LoggerFactory.getLogger(PMDTaskImpl.class);
|
||||
log.atLevel(level).log("Logging is at {}", level);
|
||||
|
@ -9,6 +9,7 @@ import java.lang.reflect.Method;
|
||||
import org.slf4j.ILoggerFactory;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.slf4j.LoggerFactoryFriend;
|
||||
import org.slf4j.bridge.SLF4JBridgeHandler;
|
||||
import org.slf4j.event.Level;
|
||||
|
||||
public final class Slf4jSimpleConfiguration {
|
||||
@ -34,8 +35,14 @@ public final class Slf4jSimpleConfiguration {
|
||||
|
||||
LoggerFactoryFriend.reset();
|
||||
}
|
||||
|
||||
|
||||
public static void disableLogging(Class<?> clazz) {
|
||||
System.setProperty("org.slf4j.simpleLogger.log." + clazz.getName(), "off");
|
||||
}
|
||||
|
||||
public static void installJulBridge() {
|
||||
if (!SLF4JBridgeHandler.isInstalled()) {
|
||||
SLF4JBridgeHandler.install();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
5
pom.xml
5
pom.xml
@ -726,6 +726,11 @@
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>${slf4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jul-to-slf4j</artifactId>
|
||||
<version>${slf4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.groovy</groupId>
|
||||
<artifactId>groovy</artifactId>
|
||||
|
Loading…
x
Reference in New Issue
Block a user