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

Log4j2编码问题

  •  0
  • alpert  · 技术社区  · 6 年前

    当我尝试在Windows 10上运行Elasticsearch时,因为主语言是英语,所以一切正常。但如果我将主语言更改为土耳其语,则会收到以下错误消息:

    2018-07-26 14:42:39,485 main ERROR Unable to locate plugin type for IfFileName
    2018-07-26 14:42:39,633 main ERROR Unable to locate plugin for IfAccumulatedFileSize
    2018-07-26 14:42:39,634 main ERROR Unable to locate plugin for IfFileName
    2018-07-26 14:42:39,637 main ERROR Unable to invoke factory method in class org.apache.logging.log4j.core.appender.rolling.action.DeleteAction for element Delete: java.lang.NullPointerException java.lang.NullPointerException
        at org.apache.logging.log4j.core.config.plugins.visitors.PluginElementVisitor.findNamedNode(PluginElementVisitor.java:103)
        at org.apache.logging.log4j.core.config.plugins.visitors.PluginElementVisitor.visit(PluginElementVisitor.java:87)
        at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.generateParameters(PluginBuilder.java:248)
        at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:135)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:958)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:898)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:890)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:890)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:890)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:513)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:237)
        at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:249)
        at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:545)
        at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:261)
        at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:163)
        at org.elasticsearch.common.logging.LogConfigurator.configure(LogConfigurator.java:119)
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:291)
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:121)
        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:112)
        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124)
        at org.elasticsearch.cli.Command.main(Command.java:90)
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92)
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:85)
    
    2018-07-26 14:42:39,645 main ERROR Null object returned for Delete in DefaultRolloverStrategy.
    

    所以这看起来像是一个字符集问题。文件编码为 UTF-8 ,我用记事本++检查。Elasticsearch有JVM选项 -Dfile.encoding=UTF-8 . 我仔细检查了log4j2.properties文件,然后 IfFileName 后面没有空间了。

    如果我改变 名字 作为 ıfFileName (其中 ı 是土耳其语字符-低I)错误变成:

    2018-07-26 14:54:25,819 main ERROR Unable to locate plugin type for ıfFileName
    

    有人知道怎么解决吗?

    1 回复  |  直到 6 年前
        1
  •  1
  •   alpert    6 年前

    添加 -Duser.language=en JVM参数修复了该问题。