通过可执行 Jar 启动时,Spring Boot 应用程序日志记录不会发生

Mar*_*dov 5 java init executable-jar maven spring-boot

我有一个 Spring boot 应用程序,当从命令行运行时,它可以完美地记录到文件系统(通过logging.level/logging.file属性):

java -jar jarfilename.jar
Run Code Online (Sandbox Code Playgroud)

但是,当我将以下内容放入 pom.xml 中以创建可执行 JAR,然后尝试将其作为 Ubuntu 中的 init 脚本运行时,日志记录根本不会发生。

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <executable>true</executable>
            </configuration>
        </plugin>
    </plugins>
</build>
Run Code Online (Sandbox Code Playgroud)

以下是我在 Linux 上运行的命令:

ln -s /path/to/executablejar.jar /etc/init.d/myapp
chmod a+x /etc/myapp
/etc/init.d/myapp start
Run Code Online (Sandbox Code Playgroud)

我想这一定是日志记录配置的某种问题,没有考虑可执行 jar 的启动方式,但我很困惑并且希望得到任何指导。

这是我在 application.properties 中的日志记录设置:

logging.level.org.springframework=error
logging.level.com.myapp=debug
logging.level.org.hibernate=error
logging.file=/path/to/a.log
Run Code Online (Sandbox Code Playgroud)