You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2022/06/20 09:03:02 UTC

[dubbo] branch 3.0 updated: [3.0] Fix switch logger NPE (#10180)

This is an automated email from the ASF dual-hosted git repository.

albumenj pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/dubbo.git


The following commit(s) were added to refs/heads/3.0 by this push:
     new 00895034d0 [3.0] Fix switch logger NPE (#10180)
00895034d0 is described below

commit 00895034d0608fffc41648e4f4c3dae20c28f891
Author: Albumen Kevin <jh...@gmail.com>
AuthorDate: Mon Jun 20 17:02:17 2022 +0800

    [3.0] Fix switch logger NPE (#10180)
    
    * [3.0] Fix switch logger NPE
    
    * fix
---
 .../java/org/apache/dubbo/qos/command/impl/SwitchLogger.java     | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/impl/SwitchLogger.java b/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/impl/SwitchLogger.java
index 0908a4b8b2..ec9a31e2bc 100644
--- a/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/impl/SwitchLogger.java
+++ b/dubbo-plugin/dubbo-qos/src/main/java/org/apache/dubbo/qos/command/impl/SwitchLogger.java
@@ -16,6 +16,7 @@
  */
 package org.apache.dubbo.qos.command.impl;
 
+import org.apache.dubbo.common.logger.Level;
 import org.apache.dubbo.common.logger.LoggerFactory;
 import org.apache.dubbo.qos.command.BaseCommand;
 import org.apache.dubbo.qos.command.CommandContext;
@@ -26,14 +27,20 @@ import org.apache.dubbo.rpc.model.FrameworkModel;
     "switchLogger slf4j"
 })
 public class SwitchLogger implements BaseCommand {
-    private FrameworkModel frameworkModel;
+    private final FrameworkModel frameworkModel;
+
+    public SwitchLogger(FrameworkModel frameworkModel) {
+        this.frameworkModel = frameworkModel;
+    }
 
     @Override
     public String execute(CommandContext commandContext, String[] args) {
         if (args.length != 1) {
             return "Unexpected argument length.";
         }
+        Level level = LoggerFactory.getLevel();
         LoggerFactory.setLoggerAdapter(frameworkModel, args[0]);
+        LoggerFactory.setLevel(level);
         return "OK";
     }
 }