在我的Spring Boot應用程序中,我想使用日誌記錄到外部文件。Java Spring Boot外部日誌文件jar
所以我配置application.properties這樣的:
# LOGGING
logging.path=/var/logs
logging.file=my-application.log
我想我們在Windows系統上的應用程序,並希望使用NSSM啓動jar文件作爲Windows服務。
另外我想要我提到的外部日誌文件。
在當前狀態下,我只在我的eclipse中測試了這個配置,名爲my-application.log
的日誌文件只存在於我的類路徑中。
沒有創建文件夾var
。
反正...
我如何配置這個應用程序日誌的工作像我想要的。
- 使用Spring啓動應用程序的罐子
- 與NSSM包裹,運行作爲Windows服務
- 有在該位置外部日誌文件「d:\應用程序\ SpringBootApp \日誌\ data.log」
不確定NSSM,但對於記錄,如果你使用maven,你可以使用【簡基於操作系統系列]路徑和文件名參數化(HTTP://行家.apache.org /實施者/實施者的規則/ requireOS.html)。否則,您可以使用[單獨的屬性文件]定義[spring profiles](http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-profiles.html)(http:// docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html#boot-features-external-config-profile-specific-properties),並從啓動腳本激活它們 – Morfic