spring boot 專案 部署 日誌 配置 及啟動
liunx 系統 啟動 spring boot 專案
nohup java -jar my-spring-boot.jar --spring.profiles.active=prod
--spring.profiles.active=prod 指的是生產環境
nohup 表示 xhell 關閉 程序仍在執行
springboot 日誌
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency>
appilcation.yml 配置
logging: pattern: console: "%d - %msg%n" path: /var/log/
springboot 預設 會找到 logback-spring.xml
<?xml version="1.0" encoding="UTF-8"?> <configuration> <include resource="org/springframework/boot/logging/logback/base.xml" /> <logger name="org.springframework.web" level="INFO"/> <logger name="org.springboot.sample" level="TRACE" />
<!-- 開發、測試環境 --> <springProfile name="dev,test"> <logger name="org.springframework.web" level="INFO"/> <logger name="org.springboot.sample" level="INFO" /> <logger name="com.zzx" level="DEBUG" /> </springProfile>
<!-- 生產環境 --> <springProfile name="pro"> <logger name="org.springframework.web" level="ERROR"/> <logger name="org.springboot.sample" level="ERROR" /> <logger name="com.zzx" level="ERROR" /> </springProfile> </configuration>