0
A
回答
0
這part of documentation解釋如何在運行時加載的結構。然後你可以將你的logback.xml
文件嵌入到你的jar或war中,並作爲資源加載,請看下面的例子。
InputStream is = YourClass.class.getResourceAsStream("embedded-logback-log.xml");
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
try {
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(context);
// Call context.reset() to clear any previous configuration, e.g. default
// configuration. For multi-step configuration, omit calling context.reset().
context.reset();
// Here you load the new configuration
configurator.doConfigure(is);
} catch (JoranException je) {
// StatusPrinter will handle this
}
StatusPrinter.printInCaseOfErrorsOrWarnings(context);
logger.info("Entering application.");
+0
Thankyou,通過使用JoranConfigurator,我可以設置強制類來登錄「信息」級別? –
+0
你可以加載(或撰寫)一個新的配置,其中更改日誌級別爲「信息」或任何你想要的。 – freedev
+0
謝謝,我改變了我的問題。我需要一個監聽器來連續檢查我的日誌配置。 –
相關問題
- 1. 如何設置偵聽器?
- 2. 動態修改Web偵聽器配置
- 3. flash as3檢查事件偵聽器
- 4. 如何檢查Tomcat是否配置爲偵聽關機?
- 5. 懷疑使用位置偵聽器
- 6. Android:如何設置Acivity.onNewIntent()的偵聽器?
- 7. 設置自定義偵聽器來偵聽整個應用程序
- 8. 如何爲更新和保存配置NHIbernate事件偵聽器?
- 9. 如何配置Symfony項目來偵聽Web服務器的80端口
- 10. 如何使用動作偵聽器中設置的變量
- 11. 如何正確配置contrib記錄器?
- 12. 觸摸偵聽器偵聽邊距
- 13. Spring JMS偵聽器容器偵聽器安裝程序超時
- 14. 如何爲Azure函數EventHub偵聽器配置接收器批處理大小?
- 15. 如何檢查數據庫服務器中當前偵聽器的狀態oracle
- 16. Lua Corona - 如何在滑動過程中偵聽widget.newScrollView偵聽器
- 17. Java:如何註冊偵聽JFrame運動的偵聽器
- 18. Android - GPS偵聽器
- 19. Infinispan CacheEntryExpired偵聽器
- 20. log4net記錄器配置
- 21. 配置AppContextListener類的應用程序偵聽器時出錯
- 22. 類應用程序偵聽器的配置錯誤
- 23. 原則模型實例觸發記錄偵聽器兩次,當偵聽器只連接
- 24. 如何將偵聽器添加到現有的偵聽器對象?
- 25. Quickblox爲聊天記錄消息偵聽器
- 26. 的JTextArea作爲偵聽的log4j記錄器
- 27. 如何使用自定義log4j.xml在netty中配置記錄器?
- 28. 如何使用PHP ping SMTP服務器並檢查MX記錄?
- 29. 如何在動作監聽器上控制焦點偵聽器?
- 30. 鼠標偵聽器和動作偵聽器的區別?
可能的[如何在運行時設置的logback配置文件http://stackoverflow.com/questions/30939814/how-to-set-logback-configuration-file-at-runtime – freedev
可能重複的副本?](http://stackoverflow.com/questions/30939814/how-to-set-logback-configuration-file-at-runtime) –