Java JMX PlatformLoggingMXBean

JMX Java About 621 words

功能

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

---------------------
Views: 272 · Posted: 2024-01-10

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

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

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


Today On History
Browsing Refresh