2017-01-11 39 views
5

好吧,我試圖配置一個logback-spring.xmlLogback配置實時重新加載(掃描= true)與彈簧啓動

我的目標是在修改後自動重新加載配置文件。

因此,這是什麼doc說:

FROM:

<configuration> 
    ... 
</configuration> 

TO:

<configuration scan="true" scanPeriod="30 seconds"> 
    ... 
</configuration> 

毫無疑問,如果我不使用任何元素:

<springProperty> 

<springProfile> 

實時重新加載沒有問題。此外,如果我不使用scan="true"springProfilespringProperty也可以很好地工作。

所以我的結論是,spring元素和scan不喜歡對方。我從類型收到錯誤信息:

16:29:39,101 |-ERROR in [email protected]:125 - no applicable action for [springProperty], current ElementPath is [[configuration][springProperty]] 
16:29:39,102 |-ERROR in [email protected]:109 - no applicable action for [springProperty], current ElementPath is [[configuration][springProperty]] 
16:29:39,102 |-ERROR in [email protected]:64 - no applicable action for [springProperty], current ElementPath is [[configuration][springProperty]] 
16:29:39,103 |-ERROR in [email protected]:29 - no applicable action for [springProfile], current ElementPath is [[configuration][springProfile]] 
16:29:39,103 |-ERROR in [email protected]:70 - no applicable action for [appender], current ElementPath is [[configuration][springProfile][appender]] 
16:29:39,103 |-ERROR in [email protected]:13 - no applicable action for [encoder], current ElementPath is [[configuration][springProfile][appender][encoder]] 
16:29:39,103 |-ERROR in [email protected]:14 - no applicable action for [pattern], current ElementPath is [[configuration][springProfile][appender][encoder][pattern]] 
16:29:39,104 |-ERROR in [email protected]:12 - no applicable action for [append], current ElementPath is [[configuration][springProfile][appender][append]] 
16:29:39,104 |-ERROR in [email protected]:10 - no applicable action for [file], current ElementPath is [[configuration][springProfile][appender][file]] 
16:29:39,104 |-ERROR in [email protected]:70 - no applicable action for [appender], current ElementPath is [[configuration][springProfile][appender]] 
16:29:39,104 |-ERROR in [email protected]:13 - no applicable action for [encoder], current ElementPath is [[configuration][springProfile][appender][encoder]] 
16:29:39,104 |-ERROR in [email protected]:14 - no applicable action for [pattern], current ElementPath is [[configuration][springProfile][appender][encoder][pattern]] 
16:29:39,105 |-ERROR in [email protected]:12 - no applicable action for [append], current ElementPath is [[configuration][springProfile][appender][append]] 
16:29:39,105 |-ERROR in [email protected]:10 - no applicable action for [file], current ElementPath is [[configuration][springProfile][appender][file]] 
16:29:39,105 |-ERROR in [email protected]:70 - no applicable action for [appender], current ElementPath is [[configuration][springProfile][appender]] 
16:29:39,105 |-ERROR in [email protected]:13 - no applicable action for [encoder], current ElementPath is [[configuration][springProfile][appender][encoder]] 
16:29:39,106 |-ERROR in [email protected]:14 - no applicable action for [pattern], current ElementPath is [[configuration][springProfile][appender][encoder][pattern]] 
16:29:39,106 |-ERROR in [email protected]:12 - no applicable action for [append], current ElementPath is [[configuration][springProfile][appender][append]] 
16:29:39,106 |-ERROR in [email protected]:10 - no applicable action for [file], current ElementPath is [[configuration][springProfile][appender][file]] 
16:29:39,106 |-ERROR in [email protected]:70 - no applicable action for [appender], current ElementPath is [[configuration][springProfile][appender]] 
16:29:39,106 |-ERROR in [email protected]:13 - no applicable action for [encoder], current ElementPath is [[configuration][springProfile][appender][encoder]] 
16:29:39,107 |-ERROR in [email protected]:14 - no applicable action for [pattern], current ElementPath is [[configuration][springProfile][appender][encoder][pattern]] 
16:29:39,107 |-ERROR in [email protected]:12 - no applicable action for [append], current ElementPath is [[configuration][springProfile][appender][append]] 
16:29:39,107 |-ERROR in [email protected]:10 - no applicable action for [file], current ElementPath is [[configuration][springProfile][appender][file]] 
16:29:39,107 |-ERROR in [email protected]:70 - no applicable action for [appender], current ElementPath is [[configuration][springProfile][appender]] 
16:29:39,107 |-ERROR in [email protected]:13 - no applicable action for [encoder], current ElementPath is [[configuration][springProfile][appender][encoder]] 
16:29:39,107 |-ERROR in [email protected]:14 - no applicable action for [pattern], current ElementPath is [[configuration][springProfile][appender][encoder][pattern]] 
16:29:39,108 |-ERROR in [email protected]:12 - no applicable action for [append], current ElementPath is [[configuration][springProfile][appender][append]] 
16:29:39,108 |-ERROR in [email protected]:10 - no applicable action for [file], current ElementPath is [[configuration][springProfile][appender][file]] 
16:29:39,108 |-ERROR in [email protected]:53 - no applicable action for [logger], current ElementPath is [[configuration][springProfile][logger]] 
16:29:39,108 |-ERROR in [email protected]:35 - no applicable action for [appender-ref], current ElementPath is [[configuration][springProfile][logger][appender-ref]] 
16:29:39,108 |-ERROR in [email protected]:54 - no applicable action for [logger], current ElementPath is [[configuration][springProfile][logger]] 
16:29:39,108 |-ERROR in [email protected]:35 - no applicable action for [appender-ref], current ElementPath is [[configuration][springProfile][logger][appender-ref]] 
16:29:39,108 |-ERROR in [email protected]:23 - no applicable action for [logger], current ElementPath is [[configuration][springProfile][logger]] 
16:29:39,108 |-ERROR in [email protected]:35 - no applicable action for [appender-ref], current ElementPath is [[configuration][springProfile][logger][appender-ref]] 
16:29:39,109 |-ERROR in [email protected]:37 - no applicable action for [logger], current ElementPath is [[configuration][springProfile][logger]] 
16:29:39,109 |-ERROR in [email protected]:35 - no applicable action for [appender-ref], current ElementPath is [[configuration][springProfile][logger][appender-ref]] 
16:29:39,109 |-ERROR in [email protected]:54 - no applicable action for [logger], current ElementPath is [[configuration][springProfile][logger]] 
16:29:39,109 |-ERROR in [email protected]:35 - no applicable action for [appender-ref], current ElementPath is [[configuration][springProfile][logger][appender-ref]] 
16:29:39,109 |-ERROR in [email protected]:54 - no applicable action for [logger], current ElementPath is [[configuration][springProfile][logger]] 
16:29:39,109 |-ERROR in [email protected]:35 - no applicable action for [appender-ref], current ElementPath is [[configuration][springProfile][logger][appender-ref]] 
16:29:39,109 |-ERROR in [email protected]:23 - no applicable action for [root], current ElementPath is [[configuration][springProfile][root]] 
16:29:39,109 |-ERROR in [email protected]:35 - no applicable action for [appender-ref], current ElementPath is [[configuration][springProfile][root][appender-ref]] 
16:29:39,109 |-ERROR in [email protected]:28 - no applicable action for [springProfile], current ElementPath is [[configuration][springProfile]] 
16:29:39,110 |-ERROR in [email protected]:72 - no applicable action for [appender], current ElementPath is [[configuration][springProfile][appender]] 
16:29:39,110 |-ERROR in [email protected]:13 - no applicable action for [encoder], current ElementPath is [[configuration][springProfile][appender][encoder]] 
16:29:39,110 |-ERROR in [email protected]:14 - no applicable action for [pattern], current ElementPath is [[configuration][springProfile][appender][encoder][pattern]] 
16:29:39,110 |-ERROR in [email protected]:14 - no applicable action for [charset], current ElementPath is [[configuration][springProfile][appender][encoder][charset]] 
16:29:39,110 |-ERROR in [email protected]:76 - no applicable action for [appender], current ElementPath is [[configuration][springProfile][appender]] 
16:29:39,110 |-ERROR in [email protected]:13 - no applicable action for [encoder], current ElementPath is [[configuration][springProfile][appender][encoder]] 
16:29:39,110 |-ERROR in [email protected]:14 - no applicable action for [pattern], current ElementPath is [[configuration][springProfile][appender][encoder][pattern]] 
16:29:39,110 |-ERROR in [email protected]:14 - no applicable action for [charset], current ElementPath is [[configuration][springProfile][appender][encoder][charset]] 
16:29:39,110 |-ERROR in [email protected]:54 - no applicable action for [logger], current ElementPath is [[configuration][springProfile][logger]] 
16:29:39,110 |-ERROR in [email protected]:38 - no applicable action for [appender-ref], current ElementPath is [[configuration][springProfile][logger][appender-ref]] 
16:29:39,111 |-ERROR in [email protected]:23 - no applicable action for [root], current ElementPath is [[configuration][springProfile][root]] 
16:29:39,111 |-ERROR in [email protected]:34 - no applicable action for [appender-ref], current ElementPath is [[configuration][springProfile][root][appender-ref]] 

因此,正如我已經說過,如果我刪除scan=true的配置工作。如果我刪除彈簧配置文件和屬性,並離開scan=true配置再次工作,但與這兩個東西是不正確的?

我認爲這很可能是不可能的,但是有人找到了這樣做的方法嗎?

編輯:在我發佈我的問題後的一個星期,春季更新了他們的documentation。仍然我在尋找答案,我認爲有可能在Spring屬性和logback配置文件之間使用一些屬性文件的中間層,因爲logback文檔說您可以將屬性文件導入到配置中。但仍然如此,仍然存在springProfile的問題。

回答