Velocity 中 SimpleLogger (SLF4j) 的配置错误
Configuration error with SimpleLogger (SLF4j) in Velocity
我在为 Spring 中的速度配置一些记录器时遇到了一些困难。我正在使用 Velocity 2.1、Spring 5.2.2 和 SLF4J 2.0.0
org.slf4j.simple.SimpleLogger object set as runtime.log.instance is not a valid org.slf4j.Logger implementation.
我正在尝试配置一些旧的废弃 Spring 类 来构建一个 JAR(它们的新版本)以在我的应用程序中使用。
velocityEngine.setProperty(RuntimeConstants.RUNTIME_LOG_INSTANCE, (new SimpleLoggerFactory()).getLogger("SpringVelocityConfiguration"));
我就是这样做的。但我不断得到例外。
抛出异常的行来自org.apache.velocity.runtime.RuntimeInstance
:
if (Logger.class.isAssignableFrom(o.getClass()))
根据我从 API 文档中看到的内容,SimpleLogger 是 Logger 的子类。所以它应该会成功,不是吗?
按要求添加依赖树:
[INFO] --- maven-dependency-plugin:3.1.1:tree (default-cli) @ spring-velocity-support ---
[INFO] com.gtt.palabs:spring-velocity-support:jar:0.0.1-SNAPSHOT
[INFO] +- commons-logging:commons-logging:jar:1.2:provided
[INFO] +- javax.servlet:javax.servlet-api:jar:4.0.1:provided
[INFO] +- org.slf4j:slf4j-api:jar:2.0.0-alpha1:provided
[INFO] +- org.slf4j:slf4j-simple:jar:2.0.0-alpha1:compile
[INFO] +- org.springframework:spring-context:jar:5.2.2.RELEASE:provided
[INFO] | +- org.springframework:spring-aop:jar:5.2.2.RELEASE:provided
[INFO] | +- org.springframework:spring-beans:jar:5.2.2.RELEASE:provided
[INFO] | \- org.springframework:spring-expression:jar:5.2.2.RELEASE:provided
[INFO] +- org.springframework:spring-core:jar:5.2.2.RELEASE:provided
[INFO] | \- org.springframework:spring-jcl:jar:5.2.2.RELEASE:provided
[INFO] +- org.springframework:spring-web:jar:5.2.2.RELEASE:provided
[INFO] +- org.springframework:spring-webmvc:jar:5.2.2.RELEASE:provided
[INFO] +- org.apache.velocity:velocity-engine-core:jar:2.1:provided
[INFO] | \- org.apache.commons:commons-lang3:jar:3.9:compile
[INFO] +- org.apache.velocity.tools:velocity-tools-generic:jar:3.0:provided
[INFO] | +- commons-beanutils:commons-beanutils:jar:1.9.3:compile
[INFO] | | \- commons-collections:commons-collections:jar:3.2.2:compile
[INFO] | +- org.apache.commons:commons-digester3:jar:3.2:compile
[INFO] | | \- cglib:cglib:jar:2.2.2:compile
[INFO] | | \- asm:asm:jar:3.3.1:compile
[INFO] | \- com.github.cliftonlabs:json-simple:jar:3.0.2:provided
[INFO] \- org.apache.velocity.tools:velocity-tools-view:jar:3.0:compile
错误:
org.apache.velocity.exception.VelocityException: Error initializing log: com.gtt.logicalprovisioning.velocity.utilities.VelocityLogger object set as runtime.log.instance is not a valid org.slf4j.Logger implementation.
at org.apache.velocity.runtime.RuntimeInstance.initializeLog(RuntimeInstance.java:958)
at org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:260)
at org.apache.velocity.app.VelocityEngine.init(VelocityEngine.java:90)
at com.gtt.logicalprovisioning.velocity.utilities.VelocityBuilderSystem.<init>(VelocityBuilderSystem.java:69)
at com.gtt.logicalprovisioning.ipflex.VelocityBuilderAction.processAction(VelocityBuilderAction.java:158)
at com.gtt.logicalprovisioning.rtp.BaseActionListType.run(BaseActionListType.java:72)
Caused by: org.apache.velocity.exception.VelocityException: com.gtt.logicalprovisioning.velocity.utilities.VelocityLogger object set as runtime.log.instance is not a valid org.slf4j.Logger implementation.
at org.apache.velocity.runtime.RuntimeInstance.initializeLog(RuntimeInstance.java:931)
... 5 more
日志行说明了一切:
org.apache.velocity.exception.VelocityException: Error initializing log:
com.gtt.logicalprovisioning.velocity.utilities.VelocityLogger
object set as runtime.log.instance
is not a valid org.slf4j.Logger implementation.
这意味着您正在使用的旧 Spring 类 在进行 Velocity 初始化之前覆盖 runtime.instance.log 属性。
我在为 Spring 中的速度配置一些记录器时遇到了一些困难。我正在使用 Velocity 2.1、Spring 5.2.2 和 SLF4J 2.0.0
org.slf4j.simple.SimpleLogger object set as runtime.log.instance is not a valid org.slf4j.Logger implementation.
我正在尝试配置一些旧的废弃 Spring 类 来构建一个 JAR(它们的新版本)以在我的应用程序中使用。
velocityEngine.setProperty(RuntimeConstants.RUNTIME_LOG_INSTANCE, (new SimpleLoggerFactory()).getLogger("SpringVelocityConfiguration"));
我就是这样做的。但我不断得到例外。
抛出异常的行来自org.apache.velocity.runtime.RuntimeInstance
:
if (Logger.class.isAssignableFrom(o.getClass()))
根据我从 API 文档中看到的内容,SimpleLogger 是 Logger 的子类。所以它应该会成功,不是吗?
按要求添加依赖树:
[INFO] --- maven-dependency-plugin:3.1.1:tree (default-cli) @ spring-velocity-support ---
[INFO] com.gtt.palabs:spring-velocity-support:jar:0.0.1-SNAPSHOT
[INFO] +- commons-logging:commons-logging:jar:1.2:provided
[INFO] +- javax.servlet:javax.servlet-api:jar:4.0.1:provided
[INFO] +- org.slf4j:slf4j-api:jar:2.0.0-alpha1:provided
[INFO] +- org.slf4j:slf4j-simple:jar:2.0.0-alpha1:compile
[INFO] +- org.springframework:spring-context:jar:5.2.2.RELEASE:provided
[INFO] | +- org.springframework:spring-aop:jar:5.2.2.RELEASE:provided
[INFO] | +- org.springframework:spring-beans:jar:5.2.2.RELEASE:provided
[INFO] | \- org.springframework:spring-expression:jar:5.2.2.RELEASE:provided
[INFO] +- org.springframework:spring-core:jar:5.2.2.RELEASE:provided
[INFO] | \- org.springframework:spring-jcl:jar:5.2.2.RELEASE:provided
[INFO] +- org.springframework:spring-web:jar:5.2.2.RELEASE:provided
[INFO] +- org.springframework:spring-webmvc:jar:5.2.2.RELEASE:provided
[INFO] +- org.apache.velocity:velocity-engine-core:jar:2.1:provided
[INFO] | \- org.apache.commons:commons-lang3:jar:3.9:compile
[INFO] +- org.apache.velocity.tools:velocity-tools-generic:jar:3.0:provided
[INFO] | +- commons-beanutils:commons-beanutils:jar:1.9.3:compile
[INFO] | | \- commons-collections:commons-collections:jar:3.2.2:compile
[INFO] | +- org.apache.commons:commons-digester3:jar:3.2:compile
[INFO] | | \- cglib:cglib:jar:2.2.2:compile
[INFO] | | \- asm:asm:jar:3.3.1:compile
[INFO] | \- com.github.cliftonlabs:json-simple:jar:3.0.2:provided
[INFO] \- org.apache.velocity.tools:velocity-tools-view:jar:3.0:compile
错误:
org.apache.velocity.exception.VelocityException: Error initializing log: com.gtt.logicalprovisioning.velocity.utilities.VelocityLogger object set as runtime.log.instance is not a valid org.slf4j.Logger implementation.
at org.apache.velocity.runtime.RuntimeInstance.initializeLog(RuntimeInstance.java:958)
at org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:260)
at org.apache.velocity.app.VelocityEngine.init(VelocityEngine.java:90)
at com.gtt.logicalprovisioning.velocity.utilities.VelocityBuilderSystem.<init>(VelocityBuilderSystem.java:69)
at com.gtt.logicalprovisioning.ipflex.VelocityBuilderAction.processAction(VelocityBuilderAction.java:158)
at com.gtt.logicalprovisioning.rtp.BaseActionListType.run(BaseActionListType.java:72)
Caused by: org.apache.velocity.exception.VelocityException: com.gtt.logicalprovisioning.velocity.utilities.VelocityLogger object set as runtime.log.instance is not a valid org.slf4j.Logger implementation.
at org.apache.velocity.runtime.RuntimeInstance.initializeLog(RuntimeInstance.java:931)
... 5 more
日志行说明了一切:
org.apache.velocity.exception.VelocityException: Error initializing log:
com.gtt.logicalprovisioning.velocity.utilities.VelocityLogger
object set as runtime.log.instance
is not a valid org.slf4j.Logger implementation.
这意味着您正在使用的旧 Spring 类 在进行 Velocity 初始化之前覆盖 runtime.instance.log 属性。