簡體   English   中英

Apache Velocity 2.0-日志綁定問題?

[英]Apache Velocity 2.0 - log binding issue?

我正在使用Apache Velocity 2.0。 我正在嘗試設置slf4j綁定。 如Apache Velocity文檔中所述,我已經設置了必需的依賴項。 這樣完成並說我現在期望使用NOPLogger,因為它沒有任何日志用法。 我的代碼如下:

// Get template engine
VelocityEngine templateEngine = new VelocityEngine();

// Init template engine
templateEngine.addProperty(RuntimeConstants.RUNTIME_LOG_INSTANCE, new NOPLoggerFactory().getLogger(""));
templateEngine.init();

我的問題是執行“ new VelocityEngine();” 我正在調試器控制台中跟蹤以下內容:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [bundleresource://23.fwk288994035:3/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [bundleresource://23.fwk288994035:8/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]

???

我非常了解Apache源代碼:

public class VelocityEngine implements RuntimeConstants
{
    private RuntimeInstance ri = new RuntimeInstance();
....
}

public class RuntimeInstance implements RuntimeConstants, RuntimeServices
{
/**
* The Runtime logger.  The default instance is the "org.apache.velocity" logger.
*/
    private Logger log = LoggerFactory.getLogger(DEFAULT_RUNTIME_LOG_NAME);
....
}

聽起來對我來說,記錄儀是在先於集成商的才能指定它的...在我的環境中。 我可能已經在運行其他一些記錄器(我所依賴的第三方貢獻),所以我得到了無聊的跟蹤。

我的分析可以嗎? 有什么分享技巧可以解決問題嗎?

這是關於重復的slf4j jar的警告,請參閱說明

當類路徑上有多個綁定時,請選擇一個且僅選擇一個您要使用的綁定,然后刪除其他綁定。 例如,如果您在類路徑上同時擁有slf4j-simple-1.8.0-alpha2.jar和slf4j-nop-1.8.0-alpha2.jar,並且希望使用nop(無操作)綁定,請刪除類路徑中的slf4j-simple-1.8.0-alpha2.jar。

如果需要在類路徑中保留slf4j-simple,則根本無法添加slf4j-nop jar。

在類路徑中根本不能有兩個slf4j綁定jar。

您需要做的是通過配置SimpleLogger來關閉Velocity日志。

例如,您可以定義以下系統屬性:

org.slf4j.simpleLogger.log.org.apache.velocity = off

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM