eolivelli commented on a change in pull request #14200:
URL: https://github.com/apache/pulsar/pull/14200#discussion_r811722928



##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/BrokersBase.java
##########
@@ -437,5 +440,62 @@ private void doShutDownBrokerGracefully(int 
maxConcurrentUnloadPerSec,
         
pulsar().getBrokerService().unloadNamespaceBundlesGracefully(maxConcurrentUnloadPerSec,
 forcedTerminateTopic);
         pulsar().closeAsync();
     }
+
+    /**
+     * dynamically update log4j2 logger level at runtime.
+     *
+     * @param targetClassName : class name to update
+     * @param targetLevel     : target log level
+     */
+    private CompletableFuture<Void> internalUpdateLoggerLevelAsync(String 
targetClassName, String targetLevel) {
+        CompletableFuture<Void> loggerLevelFuture = new CompletableFuture<>();
+        try {
+            String className;
+            // if set "ROOT" will take effect to rootLogger
+            if (targetClassName.trim().equalsIgnoreCase("ROOT")) {
+                className = LogManager.ROOT_LOGGER_NAME;
+            } else {
+                className = targetClassName;
+            }
+            Level newLevel;
+            try {
+                newLevel = Level.valueOf(targetLevel);
+                Configurator.setAllLevels(className, newLevel);
+            } catch (IllegalArgumentException | NullPointerException e) {
+                // Unknown Log Level or NULL
+                throw new RestException(Status.PRECONDITION_FAILED, "Invalid 
logger level.");
+            }
+        } catch (RestException re) {
+            throw re;
+        } catch (Exception ie) {
+            throw new RestException(Status.PRECONDITION_FAILED, "Internal 
error.");
+        }
+        return CompletableFuture.completedFuture(null);
+    }
+
+    @POST
+    @Path("/log4j/{classname}/{level}")

Review comment:
       I wouldn't use 'log4j' in this path.
   'logging' is enough.
   We are not sure that we will keep log4j forever.
   This API is broad enough to be compatible with major logging frameworks in 
the future




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to