如何解决找不到log4j2配置文件。使用默认配置:仅将错误记录到控制台?

我已经处理了一段时间了。我已经按照本文中所述更改了所有内容,甚至认为发生了错误在这种情况下,请确保在更改.xml或.properties文件中的设置时清理项目。在日食环境中。选择项目->清洁

解决方法

$ java -Dlog4j.configuration=file:///path/to/your/log4j2.xml -jar /path/to/your/jar_file.jar

写入控制台,您得到

ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.

但是,看起来配置文件也已找到并且无法解析:

    log4j:WARN Continuable parsing error 2 and column 31
    log4j:WARN Document root element "Configuration",must match DOCTYPE root "null".
    log4j:WARN Continuable parsing error 2 and column 31
    log4j:WARN Document is invalid: no grammar found.
    log4j:ERROR DOM element is - not a <log4j:configuration> element.
    log4j:WARN No appenders could be found for logger (kafka.utils.VerifiableProperties).
    log4j:WARN Please initialize the log4j system properly.
    log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.