执行器/logfile端点不再与外部logback配置一起使用 [英] Actuator /logfile endpoint no longer works with external logback configuration

查看:171
本文介绍了执行器/logfile端点不再与外部logback配置一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要滚动日志,所以我创建了一个"logback-spring.xml"文件并将其放置在src/main/resources中.完美地工作.

I needed my logs to be rolling, so I have created a "logback-spring.xml" file and placed it src/main/resources. Works flawlessly.

问题是执行器端点"/logfile"不再起作用,因为我已从"applications.yml"文件中删除了日志记录配置. 根据文档,为了使"/logfile"端点正常工作,需要设置"logging.path"或"logging.file".但是,这似乎与我的新'xml配置冲突.

The issue is that the actuator endpoint "/logfile" no longer works as I have removed the logging configuration from the "applications.yml" file. According to documentation, either "logging.path" or "logging.file" needs to be set in order to make the "/logfile" endpoint work. This however seem to conflict with my new 'xml configuration.

这是我的logback-spring.xml配置,很好:

Here is my logback-spring.xml configuration for good measure:

<configuration debug="true" scan="true">
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<property name="LOG_PATH" value="logs"/>
<property name="LOG_ARCHIVE" value="${LOG_PATH}/archive"/>

<appender name="RollingFile-Appender" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>${LOG_FILE}</file>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
        <fileNamePattern>${LOG_ARCHIVE}/bookingflow-%d{yyyy-MM-dd}.log</fileNamePattern>
        <maxHistory>30</maxHistory>
        <totalSizeCap>1GB</totalSizeCap>
    </rollingPolicy>
    <encoder>
        <pattern>%d %-5level [%thread] %logger : %msg%n</pattern>
    </encoder>
</appender>
<appender name="Async-Appender" class="ch.qos.logback.classic.AsyncAppender">
    <appender-ref ref="RollingFile-Appender"/>
</appender>

<logger name="com.novasol.bookingflow.api" level="debug">
    <appender-ref ref="Async-Appender"/>
</logger>
<springProfile name="production">
    <logger name="com.novasol.bookingflow.api" level="error">
        <appender-ref ref="Async-Appender"/>
    </logger>
</springProfile>
</configuration>    

任何指针都表示赞赏.

亲切的问候 拉斯

推荐答案

通过以下方式解决:

在application.yml

In application.yml

logging:
   config:
      classpath: "logback-spring.xml"
   file: logs/bookingflow.log

"logback-spring.xml":

The "logback-spring.xml":

<configuration debug="true" scan="true">
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<property name="LOG_ARCHIVE" value="${LOG_PATH}/archive"/>

<appender name="RollingFile-Appender" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>${LOG_PATH}/${LOG_FILE}</file>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
        <fileNamePattern>${LOG_ARCHIVE}/bookingflow-%d{yyyy-MM-dd}.log</fileNamePattern>
        <maxHistory>30</maxHistory>
        <totalSizeCap>1GB</totalSizeCap>
    </rollingPolicy>
    <encoder>
        <pattern>%d %-5level [%thread] %logger : %msg%n</pattern>
    </encoder>
</appender>
<appender name="Async-Appender" class="ch.qos.logback.classic.AsyncAppender">
    <appender-ref ref="RollingFile-Appender"/>
</appender>

<logger name="com.novasol.bookingflow.api" level="debug">
    <appender-ref ref="Async-Appender"/>
</logger>
<springProfile name="production">
    <logger name="com.novasol.bookingflow.api" level="error">
        <appender-ref ref="Async-Appender"/>
    </logger>
</springProfile>

最终找到了解决方案:

需要指定以下内容

endpoints:
  logfile:
    external-file: logs/custom.log

这篇关于执行器/logfile端点不再与外部logback配置一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆