最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

SpringBoot使用admin+actuator實(shí)現(xiàn)日志可視化的方法

 更新時(shí)間:2025年06月28日 11:20:02   作者:天宇_任  
如何在SpringBoot中使用Admin和Actuator實(shí)現(xiàn)日志可視化,需配置pom依賴、yml參數(shù)及l(fā)ogback路徑,確保兩者一致,啟動(dòng)服務(wù)后通過指定端口訪問日志界面,并檢查404錯(cuò)誤原因,感興趣的朋友一起看看吧

1:創(chuàng)建admin服務(wù)端

pom文件依賴如下

<dependency>
    <groupId>de.codecentric</groupId>
    <artifactId>spring-boot-admin-starter-server</artifactId>
    <version>2.3.1</version>
</dependency>

yml配置如下

server:
  port: 8081
management:
  trace:
    http:
      enabled: true
    endpoints:
      web:
        exposure:
          include: "*"
    endpoint:
      health:
        show-details: always

如果需要注冊(cè)到nacos或者其他注冊(cè)中心,可以按需添加

啟動(dòng)類需要加上

@EnableAdminServer注解啟動(dòng)

2:服務(wù)端配置

pom配置如下

dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
    <version>2.3.7.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    <version>2.3.7.RELEASE</version>
</dependency>
<dependency>
    <groupId>de.codecentric</groupId>
    <artifactId>spring-boot-admin-starter-client</artifactId>
    <version>2.3.1</version>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-logging</artifactId>
    <version>2.3.7.RELEASE</version>
</dependency>

yml配置如下

server:
  port: 8080  # 微服務(wù)端口
spring:
  application:
    name: clientServer  # 服務(wù)名稱
  boot:
    admin:
      client:
        url: http://localhost:8081  # Admin Server地址
logging:
  config: classpath:logback-spring.xml
  file:
    name: logs/clientServer/debug.log
  pattern:
    file: "%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n"
management:
  endpoints:
    web:
      exposure:
        include: "*"  # 暴露所有Actuator端點(diǎn)(生產(chǎn)環(huán)境建議按需配置)
  endpoint:
    health:
      show-details: always
    logfile:
      external-file: ${logging.file.name}
      enabled: true

logback-spring中的地址要和yml地址一致,例:

<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false" scan="false">
   <springProperty scop="context" name="spring.application.name" source="spring.application.name" defaultValue=""/>
   <property name="log.path" value="logs/clientServer" />
   <!-- 彩色日志格式 -->
   <property name="CONSOLE_LOG_PATTERN"
           value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}" />
   <!-- 彩色日志依賴的渲染類 -->
   <conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
   <conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
   <conversionRule conversionWord="wEx"
               converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
   <!-- Console log output -->
   <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
      <encoder>
         <pattern>${CONSOLE_LOG_PATTERN}</pattern>
      </encoder>
   </appender>
   <!-- Log file debug output -->
   <appender name="debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
      <file>${log.path}/debug.log</file>
      <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
         <fileNamePattern>${log.path}/%d{yyyy-MM}/debug.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
         <maxFileSize>50MB</maxFileSize>
         <maxHistory>30</maxHistory>
      </rollingPolicy>
      <encoder>
         <pattern>%date [%thread] %-5level [%logger{50}] %file:%line - %msg%n</pattern>
      </encoder>
   </appender>
   <!-- Log file error output -->
   <appender name="error" class="ch.qos.logback.core.rolling.RollingFileAppender">
      <file>${log.path}/error.log</file>
      <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
         <fileNamePattern>${log.path}/%d{yyyy-MM}/error.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
         <maxFileSize>50MB</maxFileSize>
         <maxHistory>30</maxHistory>
      </rollingPolicy>
      <encoder>
         <pattern>%date [%thread] %-5level [%logger{50}] %file:%line - %msg%n</pattern>
      </encoder>
      <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
         <level>ERROR</level>
      </filter>
   </appender>
   <!-- Level: FATAL 0  ERROR 3  WARN 4  INFO 6  DEBUG 7 -->
   <root level="INFO">
      <appender-ref ref="console" />
      <appender-ref ref="debug" />
      <appender-ref ref="error" />
   </root>
</configuration>

啟動(dòng)服務(wù)端,打開http://localhost:8081/

就可以看到注冊(cè)進(jìn)去的服務(wù)了

點(diǎn)擊對(duì)應(yīng)的服務(wù)名可以看到服務(wù)對(duì)應(yīng)的日志

如果日志頁面報(bào)錯(cuò)404,一定要檢查yml配置的日志路徑和logback-spring.xml中的路徑是否一致

到此這篇關(guān)于SpringBoot使用admin+actuator實(shí)現(xiàn)日志可視化的文章就介紹到這了,更多相關(guān)SpringBoot日志可視化內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Java 通配符詳解:?、? extends、? super 一篇搞懂

    Java 通配符詳解:?、? extends、? super 一篇搞懂

    本文深入解析Java泛型中的通配符(Wildcard)機(jī)制,重點(diǎn)講解無界通配符(?)、上界通配符(? extends T)和下界通配符(? super T)的用法與區(qū)別,感興趣的可以了解一下
    2025-10-10
  • Java觀察者設(shè)計(jì)模式(Observable和Observer)

    Java觀察者設(shè)計(jì)模式(Observable和Observer)

    這篇文章主要介紹了 Java觀察者設(shè)計(jì)模式(Observable和Observer)的相關(guān)資料,需要的朋友可以參考下
    2015-12-12
  • SpringBoot整合flyway實(shí)現(xiàn)自動(dòng)創(chuàng)建表的方法

    SpringBoot整合flyway實(shí)現(xiàn)自動(dòng)創(chuàng)建表的方法

    這篇文章主要介紹了SpringBoot整合flyway實(shí)現(xiàn)自動(dòng)創(chuàng)建表的方法,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-03-03
  • 基于SpringBoot+hutool實(shí)現(xiàn)項(xiàng)目的多數(shù)據(jù)源

    基于SpringBoot+hutool實(shí)現(xiàn)項(xiàng)目的多數(shù)據(jù)源

    本文介紹了基于SpringBoot和hutool實(shí)現(xiàn)多數(shù)據(jù)源的方法,通過hutool的db工具類實(shí)現(xiàn)小型業(yè)務(wù)的數(shù)據(jù)庫連接,不會(huì)影響主流程業(yè)務(wù),同時(shí)提供了官方文檔鏈接、數(shù)據(jù)源配置和測(cè)試類訪問地址,需要的朋友可以參考下
    2026-04-04
  • java.sql.SQLException問題解決以及注意事項(xiàng)

    java.sql.SQLException問題解決以及注意事項(xiàng)

    這篇文章主要給大家介紹了關(guān)于java.sql.SQLException問題解決以及注意事項(xiàng)的相關(guān)資料,這個(gè)問題其實(shí)很好解決,文中通過圖文將解決的辦法介紹的很詳細(xì),需要的朋友可以參考下
    2023-07-07
  • MyBatis 參數(shù)綁定的具體實(shí)現(xiàn)

    MyBatis 參數(shù)綁定的具體實(shí)現(xiàn)

    本文主要介紹了MyBatis 參數(shù)綁定的具體實(shí)現(xiàn),包括默認(rèn)參數(shù)名、@Param注解和POJO/DTO對(duì)象三種方式,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2026-01-01
  • java.sql.SQLException:?connection?holder?is?null錯(cuò)誤解決辦法

    java.sql.SQLException:?connection?holder?is?null錯(cuò)誤解決辦法

    這篇文章主要給大家介紹了關(guān)于java.sql.SQLException:?connection?holder?is?null錯(cuò)誤的解決辦法,這個(gè)錯(cuò)誤通常是由于連接對(duì)象為空或未正確初始化導(dǎo)致的,文中通過代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2024-02-02
  • Java實(shí)戰(zhàn)之藥品管理系統(tǒng)的實(shí)現(xiàn)

    Java實(shí)戰(zhàn)之藥品管理系統(tǒng)的實(shí)現(xiàn)

    這篇文章主要介紹了利用Java實(shí)現(xiàn)的藥品管理系統(tǒng),本項(xiàng)目屬于前后端分離的項(xiàng)目,分為兩個(gè)角色藥品管理員和取藥處人員,感興趣的小伙伴可以學(xué)習(xí)一下
    2022-04-04
  • springboot默認(rèn)掃描的路徑方式

    springboot默認(rèn)掃描的路徑方式

    這篇文章主要介紹了springboot默認(rèn)掃描的路徑方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-07-07
  • SpringMVC MVC架構(gòu)與Servlet使用詳解

    SpringMVC MVC架構(gòu)與Servlet使用詳解

    MVC設(shè)計(jì)模式一般指 MVC 框架,M(Model)指數(shù)據(jù)模型層,V(View)指視圖層,C(Controller)指控制層。使用 MVC 的目的是將 M 和 V 的實(shí)現(xiàn)代碼分離,使同一個(gè)程序可以有不同的表現(xiàn)形式。其中,View 的定義比較清晰,就是用戶界面
    2022-10-10

最新評(píng)論

来安县| 高邮市| 旬阳县| 沿河| 霍州市| 增城市| 平泉县| 武陟县| 确山县| 墨竹工卡县| 淮北市| 河东区| 广东省| 新龙县| 陈巴尔虎旗| 庆城县| 商洛市| 东辽县| 四子王旗| 喀什市| 大埔县| 奈曼旗| 德阳市| 民乐县| 和林格尔县| 聊城市| 嘉义市| 康定县| 稻城县| 平昌县| 正阳县| 来宾市| 灵台县| 富宁县| 抚顺市| 砚山县| 西藏| 新野县| 什邡市| 宁陕县| 舒城县|