Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update log config for 'Spring Boot 应用如何结合 SofaArk' #1185

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion content/zh/projects/sofa-boot/sofa-ark-spring-boot-demo/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ aliases: "/sofa-boot/docs/sofa-ark-spring-boot-demo"
5. 如何执行 Spring Boot 业务应用
6. 多 Host 与单 Host 模式
7. 如何动态卸载 Spring Boot 业务应用
8. 日志配置

## 1. 简介

Expand Down Expand Up @@ -340,4 +341,18 @@ logging.file.path=./logs

## 7. 如何动态卸载 Spring Boot 业务应用

目前 Spring boot 不支持动态卸载。如果要动态卸载,需要注册一个卸载的事件handler,请参考 sofaboot 的代码:[SofaBizUninstallEventHandler](https://github.com/sofastack/sofa-boot/blob/master/sofa-boot-project/sofa-boot-core/runtime-sofa-boot/src/main/java/com/alipay/sofa/runtime/SofaBizUninstallEventHandler.java)。
目前 Spring boot 不支持动态卸载。如果要动态卸载,需要注册一个卸载的事件handler,请参考 sofaboot 的代码:[SofaBizUninstallEventHandler](https://github.com/sofastack/sofa-boot/blob/master/sofa-boot-project/sofa-boot-core/runtime-sofa-boot/src/main/java/com/alipay/sofa/runtime/SofaBizUninstallEventHandler.java)。

## 8. 日志配置

- logback 框架配置日志参数

一般而言,建议业务应用使用 application.properties 配置日志参数,**不要写在 logback-spring.xml 中**。因为业务应用使用的 LoggerContext 是宿主应用的 LoggerContext(由宿主的类加载器加载),LoggerContext 只会在初始化时读取一次宿主应用的 logback-spring.xml,所以业务应用即使配置了 logback-spring.xml 也不会被读取。

- 切换至 log4j2 框架

排除项目各项依赖中的 logback 依赖,添加 log4j2依赖。

- SOFAArk 容器日志

参考 [Ark 日志说明](../sofa-ark-ark-log) 和 [配置文档](../sofa-ark-ark-config).