From d43a5408537666afb1d3a144c39a18fd43c9cf71 Mon Sep 17 00:00:00 2001 From: Jisha Abubaker Date: Thu, 8 Jun 2017 15:06:40 -0700 Subject: [PATCH] Logging logback appender : Class loader fix for custom enhancers Replacing system classloader with ch.qos.logback.core.util.Loader#loadClas for custom enhancers. (#2130) Fix #2123 --- .../java/com/google/cloud/logging/logback/LoggingAppender.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/google-cloud-contrib/google-cloud-logging-logback/src/main/java/com/google/cloud/logging/logback/LoggingAppender.java b/google-cloud-contrib/google-cloud-logging-logback/src/main/java/com/google/cloud/logging/logback/LoggingAppender.java index 4f6a38f1b081..4bc46ef2c435 100644 --- a/google-cloud-contrib/google-cloud-logging-logback/src/main/java/com/google/cloud/logging/logback/LoggingAppender.java +++ b/google-cloud-contrib/google-cloud-logging-logback/src/main/java/com/google/cloud/logging/logback/LoggingAppender.java @@ -19,6 +19,7 @@ import ch.qos.logback.classic.Level; import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.UnsynchronizedAppenderBase; +import ch.qos.logback.core.util.Loader; import com.google.cloud.MonitoredResource; import com.google.cloud.logging.LogEntry; import com.google.cloud.logging.Logging; @@ -143,7 +144,7 @@ private LoggingEnhancer getEnhancer(String enhancerClassName) { try { Class clz = (Class) - ClassLoader.getSystemClassLoader().loadClass(enhancerClassName.trim()); + Loader.loadClass(enhancerClassName.trim()); return clz.newInstance(); } catch (Exception ex) { // If we cannot create the enhancer we fallback to null