代码之家  ›  专栏  ›  技术社区  ›  feeeper

TorchServe显示`Console包含无效的元素或属性“JsonTemplateLayout”`

  •  0
  • feeeper  · 技术社区  · 1 年前

    我正在尝试将TorchServe配置为在JSON中登录:

    JsonTemplateLayout的首次尝试

    我添加了 log4j2.xml 使用配置 JsonTemplateLayout :

    <Console name="STDOUT" target="SYSTEM_OUT">
        <JsonTemplateLayout eventTemplateUri="classpath:EcsLayout.json"/>
    </Console>
    

    然后我运行了以下命令:

    torchserve \
    --start \
    --model-store model_store \
    --models doc_model=doc_model.mar \
    --ncs \
    --ts-config ./src/ts.config \
    --log-config ./src/log4j2.xml
    

    并且已收到警告和错误:

    WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.
    2023-05-23 18:52:00,570 main ERROR Console contains an invalid element or attribute "JsonTemplateLayout"
    

    JsonLayout的第二次尝试

    log4j2.xml :

    <Console name="STDOUT" target="SYSTEM_OUT">
        <JSONLayout compact="true" complete="false" eventEol="true"/>
    </Console>
    

    与上面相同的运行torchserve的命令也失败了。信息是:

    WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.
    2023-05-23 18:56:08,650 main ERROR Could not create plugin of type class org.apache.logging.log4j.core.layout.JsonLayout for element JSONLayout: java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ser/FilterProvider java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/ser/FilterProvider
            at org.apache.logging.log4j.core.layout.JsonLayout.<init>(JsonLayout.java:159)
            at org.apache.logging.log4j.core.layout.JsonLayout.<init>(JsonLayout.java:71)
            at org.apache.logging.log4j.core.layout.JsonLayout$Builder.build(JsonLayout.java:103)
            at org.apache.logging.log4j.core.layout.JsonLayout$Builder.build(JsonLayout.java:79)
            at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:122)
            at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:1120)
            at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:1045)
            at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:1037)
            at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:1037)
            at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:651)
            at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:247)
            at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:293)
            at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:626)
            at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:699)
            at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:716)
            at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:270)
            at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:245)
            at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:47)
            at org.apache.logging.log4j.LogManager.getContext(LogManager.java:176)
            at org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:54)
            at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:47)
            at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:33)
            at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:363)
            at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:388)
            at org.pytorch.serve.servingsdk.impl.PluginsManager.<init>(PluginsManager.java:18)
            at org.pytorch.serve.servingsdk.impl.PluginsManager.<clinit>(PluginsManager.java:17)
            at org.pytorch.serve.ModelServer.main(ModelServer.java:85)
    Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.databind.ser.FilterProvider
            at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
            at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
            at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
            ... 27 more
    
    2023-05-23 18:56:08,656 main ERROR Unable to invoke factory method in class org.apache.logging.log4j.core.layout.JsonLayout for element JSONLayout: java.lang.IllegalStateException: No factory method found for class org.apache.logging.log4j.core.layout.JsonLayout java.lang.IllegalStateException: No factory method found for class org.apache.logging.log4j.core.layout.JsonLayout
            at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.findFactoryMethod(PluginBuilder.java:236)
            at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:134)
            at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:1120)
            at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:1045)
            at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:1037)
            at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:1037)
            at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:651)
            at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:247)
            at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:293)
            at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:626)
            at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:699)
            at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:716)
            at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:270)
            at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:245)
            at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:47)
            at org.apache.logging.log4j.LogManager.getContext(LogManager.java:176)
            at org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:54)
            at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:47)
            at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:33)
            at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:363)
            at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:388)
            at org.pytorch.serve.servingsdk.impl.PluginsManager.<init>(PluginsManager.java:18)
            at org.pytorch.serve.servingsdk.impl.PluginsManager.<clinit>(PluginsManager.java:17)
            at org.pytorch.serve.ModelServer.main(ModelServer.java:85)
    

    有人能告诉我我做错了什么吗?

    我为这项任务研究的来源:

    1. Log4j Layouts docs
    2. Logging in TorchServe
    0 回复  |  直到 1 年前