karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject [karaf] branch karaf-4.1.x updated: [KARAF-5559] Change the sshd log level in log:tail & log:display commands to avoid infinite loop with ssh
Date Sat, 10 Feb 2018 08:09:31 GMT
This is an automated email from the ASF dual-hosted git repository.

jbonofre pushed a commit to branch karaf-4.1.x
in repository https://gitbox.apache.org/repos/asf/karaf.git


The following commit(s) were added to refs/heads/karaf-4.1.x by this push:
     new 2a30a99  [KARAF-5559] Change the sshd log level in log:tail & log:display commands
to avoid infinite loop with ssh
2a30a99 is described below

commit 2a30a99243bb47c5bbe90aef9d864d3e0b248ec6
Author: Jean-Baptiste Onofré <jbonofre@apache.org>
AuthorDate: Sat Feb 10 07:20:10 2018 +0100

    [KARAF-5559] Change the sshd log level in log:tail & log:display commands to avoid
infinite loop with ssh
---
 .../src/main/resources/resources/etc/org.ops4j.pax.logging.cfg |  4 ++++
 log/src/main/java/org/apache/karaf/log/command/DisplayLog.java |  5 +++++
 log/src/main/java/org/apache/karaf/log/command/LogTail.java    | 10 ++++++++++
 3 files changed, 19 insertions(+)

diff --git a/assemblies/features/base/src/main/resources/resources/etc/org.ops4j.pax.logging.cfg
b/assemblies/features/base/src/main/resources/resources/etc/org.ops4j.pax.logging.cfg
index 0c9d54e..52b68b2 100644
--- a/assemblies/features/base/src/main/resources/resources/etc/org.ops4j.pax.logging.cfg
+++ b/assemblies/features/base/src/main/resources/resources/etc/org.ops4j.pax.logging.cfg
@@ -33,6 +33,10 @@ log4j2.rootLogger.appenderRef.Console.filter.threshold.level = ${karaf.log.conso
 
 # Loggers configuration
 
+# SSHD logger
+log4j2.logger.sshd.name = org.apache.sshd
+log4j2.logger.sshd.level = INFO
+
 # Spifly logger
 log4j2.logger.spifly.name = org.apache.aries.spifly
 log4j2.logger.spifly.level = WARN
diff --git a/log/src/main/java/org/apache/karaf/log/command/DisplayLog.java b/log/src/main/java/org/apache/karaf/log/command/DisplayLog.java
index 076b8ec..16a3296 100644
--- a/log/src/main/java/org/apache/karaf/log/command/DisplayLog.java
+++ b/log/src/main/java/org/apache/karaf/log/command/DisplayLog.java
@@ -42,6 +42,8 @@ public class DisplayLog implements Action {
     public final static int INFO_INT  = 6;
     public final static int DEBUG_INT = 7;
 
+    private final static String SSHD_LOGGER = "org.apache.sshd";
+
     @Option(name = "-n", aliases = {}, description="Number of entries to display", required
= false, multiValued = false)
     int entries;
 
@@ -68,8 +70,11 @@ public class DisplayLog implements Action {
     public Object execute() throws Exception {
         final PrintStream out = System.out;
         int minLevel = getMinLevel(level);
+        String sshdLoggerLevel = logService.getLevel(SSHD_LOGGER).get(SSHD_LOGGER);
+        logService.setLevel(SSHD_LOGGER, "ERROR");
         display(out, minLevel);
         out.println();
+        logService.setLevel(SSHD_LOGGER, sshdLoggerLevel);
         return null;
     }
 
diff --git a/log/src/main/java/org/apache/karaf/log/command/LogTail.java b/log/src/main/java/org/apache/karaf/log/command/LogTail.java
index dc67e26..7d4ab50 100644
--- a/log/src/main/java/org/apache/karaf/log/command/LogTail.java
+++ b/log/src/main/java/org/apache/karaf/log/command/LogTail.java
@@ -74,7 +74,12 @@ public class LogTail extends DisplayLog {
      * Track LogService dynamically so we can react when the log core bundle stops even while
we block for the tail
      */
     private final class LogServiceTracker extends ServiceTracker<LogService, LogService>
{
+
+        private final static String SSHD_LOGGER = "org.apache.sshd";
+
         private final PaxAppender appender;
+
+        private String sshdLoggerLevel;
     
         private LogServiceTracker(BundleContext context, Class<LogService> clazz,
                                   ServiceTrackerCustomizer<LogService, LogService>
customizer,
@@ -86,12 +91,17 @@ public class LogTail extends DisplayLog {
         @Override
         public LogService addingService(ServiceReference<LogService> reference) {
             LogService service = super.addingService(reference);
+            sshdLoggerLevel = service.getLevel(SSHD_LOGGER).get(SSHD_LOGGER);
+            service.setLevel(SSHD_LOGGER, "ERROR");
             service.addAppender(appender);
             return service;
         }
     
         @Override
         public void removedService(ServiceReference<LogService> reference, LogService
service) {
+            if (sshdLoggerLevel != null) {
+                service.setLevel(SSHD_LOGGER, sshdLoggerLevel);
+            }
             service.removeAppender(appender);
             stopTail();
         }

-- 
To stop receiving notification emails like this one, please contact
jbonofre@apache.org.

Mime
View raw message