我正在尝试为生产环境进行设置,因此我希望将log4j.properties
保留在我的应用程序jar文件之外。
为此,我将application.properties
和log4j.properties
文件与我的spring-boot jar文件保持平行。我在application.properties中给了logging.config: file:log4j.properties
。这似乎不起作用。 Spring仍在拾取log4j.properties文件,该文件放在jar文件中。
我已尝试在logging.config
属性中提供绝对路径,例如C:\Users\furquan\project\jars\log4j.properties
,但仍然使用的log4j.properties是jar文件中的那个。
请帮忙,重要!!!
答案 0 :(得分:0)
ThingName: thing_name1
Property1: 0
Property2: sure
ThingName: thing_name2
Property1: 34
Property2: absolutely
{"thing_name1":{"property1":0,"property2":"sure"},"thing_name2":{"property1":34,"property2":"absolutely"}}
或者您可以在-Dlogging.config=/path/to/log4j.properties
或application.properties
。
来自26.5 Custom log configuration
只需注意:
Spring boot 1.4之后,Log4j 1支持已被删除。所以也许您可以考虑使用默认的logback,或者使用log4j2。