最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Logback File Appender in a Spring Boot Native Image - Stack Overflow

programmeradmin4浏览0评论

I am trying to configure logging into a file in a Spring Boot native image. According to this answer, Logback should be configurable with xml.

So I created the following logback-spring.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>

    <include resource="/springframework/boot/logging/logback/defaults.xml" />
    <include resource="/springframework/boot/logging/logback/console-appender.xml" />

    <root level="INFO">
        <appender-ref ref="CONSOLE" />
    </root>

    <springProfile name="native">
        <property name="LOG_FILE" value="log/my-app.log"/>
        <include resource="/springframework/boot/logging/logback/file-appender.xml" />
        <root>
            <appender-ref ref="FILE" />
        </root>
    </springProfile>

</configuration>

When I build the image with mvn -Pnative spring-boot:build-image and run it with docker run --rm -v /tmp/log:/workspace/log docker.io/library/my-app:0.0.1, the log file doesn't created.

The logging config works correctly when running as a normal java app.

发布评论

评论列表(0)

  1. 暂无评论