亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

使用Spring Boot的LoggersEndpoint管理日志級別

 更新時間:2023年11月02日 08:35:32   作者:codecraft  
這篇文章主要為大家介紹了使用Spring Boot的LoggersEndpoint管理日志級別,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪

本文主要研究一下springboot的LoggersEndpoint

LoggersEndpoint

/**
 * {@link Endpoint @Endpoint} to expose a collection of {@link LoggerConfiguration}s.
 *
 * @author Ben Hale
 * @author Phillip Webb
 * @author HaiTao Zhang
 * @since 2.0.0
 */
@Endpoint(id = "loggers")
public class LoggersEndpoint {
    private final LoggingSystem loggingSystem;
    private final LoggerGroups loggerGroups;
    /**
     * Create a new {@link LoggersEndpoint} instance.
     * @param loggingSystem the logging system to expose
     * @param loggerGroups the logger group to expose
     */
    public LoggersEndpoint(LoggingSystem loggingSystem, LoggerGroups loggerGroups) {
        Assert.notNull(loggingSystem, "LoggingSystem must not be null");
        Assert.notNull(loggerGroups, "LoggerGroups must not be null");
        this.loggingSystem = loggingSystem;
        this.loggerGroups = loggerGroups;
    }
    //......
}
springboot的actuator定義了LoggersEndpoint,它構造器依賴loggingSystem及l(fā)oggerGroups

loggers

@ReadOperation
    public Map<String, Object> loggers() {
        Collection<LoggerConfiguration> configurations = this.loggingSystem.getLoggerConfigurations();
        if (configurations == null) {
            return Collections.emptyMap();
        }
        Map<String, Object> result = new LinkedHashMap<>();
        result.put("levels", getLevels());
        result.put("loggers", getLoggers(configurations));
        result.put("groups", getGroups());
        return result;
    }
    private NavigableSet<LogLevel> getLevels() {
        Set<LogLevel> levels = this.loggingSystem.getSupportedLogLevels();
        return new TreeSet<>(levels).descendingSet();
    }
    private Map<String, LoggerLevels> getLoggers(Collection<LoggerConfiguration> configurations) {
        Map<String, LoggerLevels> loggers = new LinkedHashMap<>(configurations.size());
        for (LoggerConfiguration configuration : configurations) {
            loggers.put(configuration.getName(), new SingleLoggerLevels(configuration));
        }
        return loggers;
    }
    private Map<String, LoggerLevels> getGroups() {
        Map<String, LoggerLevels> groups = new LinkedHashMap<>();
        this.loggerGroups.forEach((group) -> groups.put(group.getName(),
                new GroupLoggerLevels(group.getConfiguredLevel(), group.getMembers())));
        return groups;
    }
LoggersEndpoint定義了loggers的read操作,返回levels、loggers、groups

loggerLevels

@ReadOperation
    public LoggerLevels loggerLevels(@Selector String name) {
        Assert.notNull(name, "Name must not be null");
        LoggerGroup group = this.loggerGroups.get(name);
        if (group != null) {
            return new GroupLoggerLevels(group.getConfiguredLevel(), group.getMembers());
        }
        LoggerConfiguration configuration = this.loggingSystem.getLoggerConfiguration(name);
        return (configuration != null) ? new SingleLoggerLevels(configuration) : null;
    }
LoggersEndpoint定義了loggerLevels的read操作,它接受name,返回對應的GroupLoggerLevels或者SingleLoggerLevels

configureLogLevel

@WriteOperation
    public void configureLogLevel(@Selector String name, @Nullable LogLevel configuredLevel) {
        Assert.notNull(name, "Name must not be empty");
        LoggerGroup group = this.loggerGroups.get(name);
        if (group != null && group.hasMembers()) {
            group.configureLogLevel(configuredLevel, this.loggingSystem::setLogLevel);
            return;
        }
        this.loggingSystem.setLogLevel(name, configuredLevel);
    }
LoggersEndpoint定義了configureLogLevel這個write操作,它可用于變更logger的級別

小結

springboot的actuator定義了LoggersEndpoint,它定義了loggers的read操作,返回levels、loggers、groups;定義了loggerLevels的read操作,它接受name,返回對應的GroupLoggerLevels或者SingleLoggerLevels;定義了configureLogLevel這個write操作,可用于變更logger的級別。

以上就是使用Spring Boot的LoggersEndpoint管理日志級別的詳細內容,更多關于springboot LoggersEndpoint的資料請關注腳本之家其它相關文章!

相關文章

  • Java?多線程并發(fā)LockSupport

    Java?多線程并發(fā)LockSupport

    這篇文章主要介紹了Java?多線程并發(fā)LockSupport,LockSupport?類是用于創(chuàng)建鎖和其他同步類的基本線程阻塞原語,更多相關內容需要得小伙伴可以參考一下下面文章內容
    2022-06-06
  • Java logback日志的簡單使用

    Java logback日志的簡單使用

    這篇文章主要介紹了Java logback日志的使用詳解,幫助大家更好的理解和學習使用Java,感興趣的朋友可以了解下
    2021-03-03
  • 詳解SpringMVC中的日期處理和文件上傳操作

    詳解SpringMVC中的日期處理和文件上傳操作

    這篇文章主要為大家詳細介紹了SpringMVC中的日期處理和文件上傳操作方法,文中的示例代碼講解詳細,對我們學習有一定借鑒價值,需要的可以參考一下
    2022-08-08
  • 有關IntelliJ IDEA中LeetCode插件配置問題

    有關IntelliJ IDEA中LeetCode插件配置問題

    這篇文章主要介紹了關于IntelliJ IDEA中LeetCode插件配置問題,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-08-08
  • Java泛型和Class類用法示例

    Java泛型和Class類用法示例

    這篇文章主要介紹了Java泛型和Class類用法,結合實例形式分析了java使用泛型限制class類避免強制類型轉換相關操作技巧,需要的朋友可以參考下
    2019-07-07
  • Java的Swing編程中使用SwingWorker線程模式及頂層容器

    Java的Swing編程中使用SwingWorker線程模式及頂層容器

    這篇文章主要介紹了在Java的Swing編程中使用SwingWorker線程模式及頂層容器的方法,適用于客戶端圖形化界面軟件的開發(fā),需要的朋友可以參考下
    2016-01-01
  • java實現(xiàn)隨機生成驗證碼圖片

    java實現(xiàn)隨機生成驗證碼圖片

    這篇文章主要為大家詳細介紹了java實現(xiàn)隨機生成驗證碼圖片,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2019-12-12
  • MyBatis流式查詢的三種實現(xiàn)方法

    MyBatis流式查詢的三種實現(xiàn)方法

    流式查詢指的是查詢成功后不是返回一個集合而是返回一個迭代器,應用每次從迭代器取一條查詢結果,本文介紹了MyBatis流式查詢的實現(xiàn),感興趣的可以了解一下
    2021-05-05
  • Java的MyBatis框架中XML映射緩存的使用教程

    Java的MyBatis框架中XML映射緩存的使用教程

    MyBatis程序在做好XML映射后能夠有緩存的功能,這樣映射過SQL語句的配置以后就可以拿過來直接用了,這里我們來一起總結一下Java的MyBatis框架中XML映射緩存的使用教程
    2016-06-06
  • Java設計模式之外觀模式

    Java設計模式之外觀模式

    這篇文章介紹了Java設計模式之外觀模式,文中通過示例代碼介紹的非常詳細。對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2022-09-09

最新評論