【问题标题】:How to config logging in Apache Ignite, sfl4j or log4j如何在 Apache Ignite、sfl4j 或 log4j 中配置日志记录
【发布时间】:2019-05-31 10:08:02
【问题描述】:

我使用 Apache Ignite 创建了 spring-boot 应用程序,并希望在服务器端和客户端配置日志记录。我遵循了https://apacheignite.readme.io/docs/logging 的说明,但我在日志记录方面遇到了一些问题。 对于 Slf4j

<property name="gridLogger">
    <bean class="org.apache.ignite.logger.slf4j.Slf4jLogger"/>
</property>

如果我设置 GNITE_QUIET=false 在服务器端我得到

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".

好的,我在 $IGNITE_HOME/libs/ignite-slf4j/slf4j-log4j12 和 log4j 中添加了库

log4j:WARN No appenders could be found for logger (org.apache.ignite.internal.util.typedef.G).
log4j:WARN Please initialize the log4j system properly.

我尝试设置 -Dlog4j.configurationFile=config/log4j.xml,但没有帮助。

在服务器端,我设法设置了日志记录

<property name="gridLogger">
     <bean class="org.apache.ignite.logger.log4j.Log4JLogger">
          <constructor-arg type="java.lang.String" value="log4j.xml"/>
    </bean>
</property>

但在 spring-boot ms 我得到了

Caused by: class org.apache.ignite.IgniteCheckedException: Log4j configuration path was not found: config/log4j.xml

如果我设置绝对路径就可以了

<constructor-arg type="java.lang.String"  value="/home/username/work/ignite/config/log4j.xml"/>

但这不是我需要的。如何正确配置服务器/客户端的日志?

【问题讨论】:

    标签: spring-boot logging log4j slf4j ignite


    【解决方案1】:

    根据您的第一个错误,您使用 maven 吗?如果是,您是否尝试将以下依赖项包含到您的 POM 文件中?

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.25</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>1.7.25</version>
            <scope>test</scope>
        </dependency>
    

    “找不到 Log4j 配置路径”可能是因为您将配置放置到不属于您的项目的文件夹中。如果您不想使用完整路径,只需将其移至项目的“资源”文件夹即可。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-03-14
      • 2011-12-29
      • 2013-03-26
      • 1970-01-01
      • 2010-09-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多