AMBARI-16187. Jersey and Jetty logs should go to server log file. (mpapirkovskyy)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/41323109 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/41323109 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/41323109 Branch: refs/heads/trunk Commit: 4132310990655c0d7a442ad4b0d915ae2b6db1b1 Parents: d033fa7 Author: Myroslav Papirkovskyi <[email protected]> Authored: Thu Apr 28 19:23:58 2016 +0300 Committer: Myroslav Papirkovskyi <[email protected]> Committed: Fri Apr 29 20:11:04 2016 +0300 ---------------------------------------------------------------------- ambari-server/conf/unix/log4j.properties | 6 ++++++ ambari-server/pom.xml | 5 +++++ .../apache/ambari/server/controller/AmbariServer.java | 14 ++++++++++++++ 3 files changed, 25 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/41323109/ambari-server/conf/unix/log4j.properties ---------------------------------------------------------------------- diff --git a/ambari-server/conf/unix/log4j.properties b/ambari-server/conf/unix/log4j.properties index 3cb7fd0..01bbc4c 100644 --- a/ambari-server/conf/unix/log4j.properties +++ b/ambari-server/conf/unix/log4j.properties @@ -71,6 +71,12 @@ log4j.appender.eclipselink.MaxBackupIndex=10 log4j.appender.eclipselink.layout=org.apache.log4j.PatternLayout log4j.appender.eclipselink.layout.ConversionPattern=%m%n +# Jersey +log4j.logger.org.glassfish.jersey=WARN,file + +# Jetty +log4j.logger.org.eclipse.jetty=WARN,file + # Audit logging log4j.logger.audit=INFO,audit log4j.additivity.audit=false http://git-wip-us.apache.org/repos/asf/ambari/blob/41323109/ambari-server/pom.xml ---------------------------------------------------------------------- diff --git a/ambari-server/pom.xml b/ambari-server/pom.xml index 165ba8f..20d3fab 100644 --- a/ambari-server/pom.xml +++ b/ambari-server/pom.xml @@ -1363,6 +1363,11 @@ <version>[0.9.5.2]</version> <scope>compile</scope> </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>jul-to-slf4j</artifactId> + <version>1.7.2</version> + </dependency> </dependencies> <pluginRepositories> http://git-wip-us.apache.org/repos/asf/ambari/blob/41323109/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java index 0527cbc..5c9004b 100644 --- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java +++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java @@ -29,6 +29,7 @@ import java.util.EnumSet; import java.util.Enumeration; import java.util.HashMap; import java.util.Map; +import java.util.logging.LogManager; import javax.crypto.BadPaddingException; import javax.servlet.DispatcherType; @@ -140,6 +141,7 @@ import org.eclipse.jetty.util.ssl.SslContextFactory; import org.eclipse.jetty.util.thread.QueuedThreadPool; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.slf4j.bridge.SLF4JBridgeHandler; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.security.core.context.SecurityContextHolder; @@ -282,6 +284,9 @@ public class AmbariServer { @SuppressWarnings("deprecation") public void run() throws Exception { + setupJulLogging(); + + performStaticInjection(); initDB(); server = new Server(); @@ -648,6 +653,15 @@ public class AmbariServer { } /** + * installs bridge handler which redirects log entries from JUL to Slf4J + */ + private void setupJulLogging() { + // install handler for jul to slf4j translation + LogManager.getLogManager().reset(); + SLF4JBridgeHandler.install(); + } + + /** * Calculate desired Acceptor and Selector for Jetty agent ServerConnector * @param serverForAgent * the Jetty server instance which will have the selector and Acceptor set on it
