欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

使用Spring Boot的LoggersEndpoint管理日志級(jí)別

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

本文主要研究一下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,它構(gòu)造器依賴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,返回對(duì)應(yīng)的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這個(gè)write操作,它可用于變更logger的級(jí)別

小結(jié)

springboot的actuator定義了LoggersEndpoint,它定義了loggers的read操作,返回levels、loggers、groups;定義了loggerLevels的read操作,它接受name,返回對(duì)應(yīng)的GroupLoggerLevels或者SingleLoggerLevels;定義了configureLogLevel這個(gè)write操作,可用于變更logger的級(jí)別。

以上就是使用Spring Boot的LoggersEndpoint管理日志級(jí)別的詳細(xì)內(nèi)容,更多關(guān)于springboot LoggersEndpoint的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

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

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

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

    Java logback日志的簡(jiǎn)單使用

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

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

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

    有關(guān)IntelliJ IDEA中LeetCode插件配置問題

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

    Java泛型和Class類用法示例

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

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

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

    java實(shí)現(xiàn)隨機(jī)生成驗(yàn)證碼圖片

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

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

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

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

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

    Java設(shè)計(jì)模式之外觀模式

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

最新評(píng)論