karaf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (KARAF-5559) log:tail kills ssh & karaf when root logger is in DEBUG
Date Sat, 10 Feb 2018 08:08:00 GMT

    [ https://issues.apache.org/jira/browse/KARAF-5559?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16359319#comment-16359319
] 

ASF GitHub Bot commented on KARAF-5559:
---------------------------------------

jbonofre closed pull request #448: [KARAF-5559] Change the sshd log level in log:tail &
log:display commands to avoid infinite loop using ssh
URL: https://github.com/apache/karaf/pull/448
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 6cd8240fa6..ec0b7737fc 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
@@ -43,6 +43,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 076b8ecbab..16a3296c90 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 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 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 dc67e2627e..7d4ab50b69 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 @@ private synchronized void stopTail() {
      * 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 @@ private LogServiceTracker(BundleContext context, Class<LogService>
clazz,
         @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();
         }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> log:tail kills ssh & karaf when root logger is in DEBUG
> -------------------------------------------------------
>
>                 Key: KARAF-5559
>                 URL: https://issues.apache.org/jira/browse/KARAF-5559
>             Project: Karaf
>          Issue Type: Bug
>          Components: karaf-logging, karaf-shell
>    Affects Versions: 4.1.4, 4.2.0.M2
>            Reporter: Jean-Baptiste Onofré
>            Assignee: Jean-Baptiste Onofré
>            Priority: Major
>             Fix For: 4.2.0, 4.1.5
>
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message