简体   繁体   English

Hazelcast log4j 配置产生“java.lang.NoClassDefFoundError: org/apache/log4j/Logger”错误

[英]Hazelcast log4j configuration produces "java.lang.NoClassDefFoundError: org/apache/log4j/Logger" error

I am trying to setup Hazelcast log4j logging on Windows using the latest version.我正在尝试使用最新版本在 Windows 上设置 Hazelcast log4j 日志记录。

I added the config:我添加了配置:

  <properties>
        <property name="hazelcast.logging.type">log4j</property>
  </properties>

I run the following command from the hazelcast bin folder:我从 hazelcast bin 文件夹中运行以下命令:

java -jar ..\lib\hazelcast-3.12.2.jar com.hazelcast.core.server.StartServer

This produces the following error:这会产生以下错误:

 Dec 20, 2019 8:44:56 AM com.hazelcast.config.AbstractConfigLocator
    INFO: Loading 'hazelcast.xml' from the working directory.
    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Logger
            at com.hazelcast.logging.Log4jFactory.createLogger(Log4jFactory.java:29)
            at com.hazelcast.logging.LoggerFactorySupport$1.createNew(LoggerFactorySupport.java:32)
                ...
    Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
            at java.net.URLClassLoader.findClass(Unknown Source)
                ...

I see that Hazelcast needs log4j version 1.2.17 so i downloaded that from maven and put it in a folder.我看到 Hazelcast 需要 log4j 版本 1.2.17,所以我从 maven 下载了它并将其放在一个文件夹中。 I then ran the following:然后我运行了以下命令:

 java -cp ..\..\log4j\log4j-1.2.17.jar -jar ..\lib\hazelcast-3.12.2.jar com.hazelcast.core.server.StartServer

However, I have read that you can't specify the classpath and the jar in the same statement.但是,我读到您不能在同一个语句中指定类路径和 jar。 The hazelcast jars do not contain the log4j jar file. Hazelcast jar 不包含 log4j jar 文件。 It seems that they should when packaged.似乎他们应该在打包时。

Can anyone help with this please.任何人都可以帮忙解决这个问题。

In order to tell log4j how to get the config file, you must add the following line in the config file:为了告诉 log4j 如何获取配置文件,您必须在配置文件中添加以下行:

    <property name="log4j2.configuration">/path/to/properties/log4j2.properties</property>

so it looks like this:所以它看起来像这样:

  <properties>
        <property name="hazelcast.logging.type">log4j</property>
        <property name="log4j2.configuration">/path/to/properties/log4j2.properties</property>
  </properties>

Then you have to edit the log4j2.properties file, as stated in the documentation: https://docs.hazelcast.org/docs/latest/manual/html-single/index.html#logging-configuration然后你必须编辑 log4j2.properties 文件,如文档中所述: https ://docs.hazelcast.org/docs/latest/manual/html-single/index.html#logging-configuration

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Elasticsearch Java API错误java.lang.NoClassDefFoundError:org / apache / logging / log4j / Logger - Elasticsearch java api error java.lang.NoClassDefFoundError: org/apache/logging/log4j/Logger java.lang.NoClassDefFoundError:org / apache / log4j / Priority - java.lang.NoClassDefFoundError: org/apache/log4j/Priority java.lang.NoClassDefFoundError:org / apache / log4j / Priority - java.lang.NoClassDefFoundError: org/apache/log4j/Priority java.lang.NoClassDefFoundError:org / apache / log4j / PropertyConfigurator - java.lang.NoClassDefFoundError: org/apache/log4j/PropertyConfigurator log4j和java.lang.NoClassDefFoundError:org / apache / log4j / Layout - log4j and java.lang.NoClassDefFoundError: org/apache/log4j/Layout java.lang.NoClassDefFoundError:org / apache / logging / log4j / Logger - java.lang.NoClassDefFoundError: org/apache/logging/log4j/Logger 引起:java.lang.NoClassDefFoundError:org/apache/log4j/Logger - Caused By: java.lang.NoClassDefFoundError: org/apache/log4j/Logger 由以下原因引起:java.lang.NoClassDefFoundError:XPages 中的 org/apache/log4j/Logger - Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Logger in XPages Log4j 迁移-异常 java.lang.NoClassDefFoundError: org/apache/log4j/FileAppender - Log4j migration -Exception java.lang.NoClassDefFoundError: org/apache/log4j/FileAppender 尝试在插件类型项目中添加log4j。 错误:java.lang.NoClassDefFoundError:org / apache / log4j / PropertyConfigurator - Trying to add log4j in plugin type project. Error : java.lang.NoClassDefFoundError: org/apache/log4j/PropertyConfigurator
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM