Java OpenResty Spring Spring Boot MySQL Redis MongoDB PostgreSQL Linux Android Nginx 面试 小程序 Arthas JVM AQS juc Kubernetes Docker 诊断工具


Java JMX PlatformLoggingMXBean

JMX Java 大约 621 字

功能

PlatformLoggingMXBean可以获取Java服务的运行时的日志级别和名称

代码

public class PlatformLoggingMXBeanTest {

    public static void main(String[] args) {
        PlatformLoggingMXBean platformLoggingMXBean = ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class);
        for (String loggerName : platformLoggingMXBean.getLoggerNames()) {
            System.out.println(loggerName);
            System.out.println(platformLoggingMXBean.getLoggerLevel(loggerName));
            System.out.println("---------------------");
        }
    }

}

输出:如果在Spring Boot项目中,输出的内容会更多

INFO
---------------------
global

---------------------
阅读 80 · 发布于 2024-01-10

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb

扫描下方二维码关注公众号和小程序↓↓↓

扫描二维码关注我
昵称:
随便看看 换一批