Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Null Pointer Exception with slf4j-log4j12-1.7.30 (Fluent-logger incompatible with the new version)

未关闭
#89 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
42/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
java

调研方向

使用 spark-submit 场景复现 slf4j-log4j12 1.7.30 中的失败,并与 1.7.18 进行比较。首先阅读 FluentLogger.getLogger、FluentLoggerFactory.getLogger 和 RawSocketSender 的初始化过程。完成标准是:使用较新的 SLF4J 版本时,FluentLogger.getLogger 不再抛出 NullPointerException,并且现有的 logging 路径仍可使用。

由索引模型根据 Issue 内容生成。

描述

When running spark-submit with slf4j-log4j12-1.7.18.jar in the ClassPath, FluentLogger works with no issues.
When we use version 1.7.30 which comes with Spark3.0, Fluentlogger.getLogger throws a null pointer exception.

This is the offending commit introduced in 1.7.19  which was done to fix a NullPointerException. Its force initializing rootLogger to fix a NPE in multithreaded scenarios looks like. The irony is this is the commit which is causing NullPointerException for us
https://github.com/qos-ch/slf4j/commit/111b8e581e247b33bb2fe66bd0118399e0b49a90

Can we upgrade the version of slf4j-api in FluentLogger to latest 1.7.30 and make it compatible?

hdiuser@hn0-d0140a:/usr/hdp/4.1-0/spark2/jars$ spark-submit --version
SPARK_MAJOR_VERSION is set to 2, using Spark2
Unexpected problem occured during version sanity check
Reported exception:
java.lang.NullPointerException
at org.slf4j.LoggerFactory.versionSanityCheck(LoggerFactory.java:267)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:126)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:412)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:357)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:383)
at org.fluentd.logger.sender.RawSocketSender.(RawSocketSender.java:34)
at org.fluentd.logger.FluentLoggerFactory.getLogger(FluentLoggerFactory.java:72)
at org.fluentd.logger.FluentLoggerFactory.getLogger(FluentLoggerFactory.java:51)
at org.fluentd.logger.FluentLogger.getLogger(FluentLogger.java:40)
at com.mdsdclient.MdsLogger.(Unknown Source)
at com.log4jappender.common.logger.HdInsightLoggerLinux.(Unknown Source)
at com.log4jappender.common.logger.HdInsightLoggerFactory.getLogger(Unknown Source)
at com.log4jappender.common.appendercore.AnonymizeLogAppenderCommon.getLogger(Unknown Source)
at com.log4jappender.common.appendercore.AnonymizeLogAppenderCommon.(Unknown Source)
at com.microsoft.log4jappender.AnonymizeLogAppender.activateOptions(Unknown Source)
at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:307)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:172)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:104)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:842)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:768)
at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:648)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:514)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:580)
at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:526)
at org.apache.log4j.LogManager.(LogManager.java:127)
at org.slf4j.impl.Log4jLoggerFactory.(Log4jLoggerFactory.java:66)
at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:72)
at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:45)
at org.apache.spark.internal.Logging$.org$apache$spark$internal$Logging$$isLog4j12(Logging.scala:222)
at org.apache.spark.internal.Logging.initializeLogging(Logging.scala:127)
at org.apache.spark.internal.Logging.initializeLogIfNecessary(Logging.scala:111)
at org.apache.spark.internal.Logging.initializeLogIfNecessary$(Logging.scala:105)
at org.apache.spark.deploy.SparkSubmit.initializeLogIfNecessary(SparkSubmit.scala:75)
at org.apache.spark.deploy.SparkSubmit.doSubmit(SparkSubmit.scala:83)
at org.apache.spark.deploy.SparkSubmit$$anon$2.doSubmit(SparkSubmit.scala:1007)
at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:1016)
at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
Exception in thread "main" java.lang.ExceptionInInitializerError
at org.fluentd.logger.FluentLoggerFactory.getLogger(FluentLoggerFactory.java:72)
at org.fluentd.logger.FluentLoggerFactory.getLogger(FluentLoggerFactory.java:51)
at org.fluentd.logger.FluentLogger.getLogger(FluentLogger.java:40)
at com.mdsdclient.MdsLogger.(Unknown Source)
at com.log4jappender.common.logger.HdInsightLoggerLinux.(Unknown Source)
at com.log4jappender.common.logger.HdInsightLoggerFactory.getLogger(Unknown Source)
at com.log4jappender.common.appendercore.AnonymizeLogAppenderCommon.getLogger(Unknown Source)
at com.log4jappender.common.appendercore.AnonymizeLogAppenderCommon.(Unknown Source)
at com.log4jappender.AnonymizeLogAppender.activateOptions(Unknown Source)
at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:307)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:172)
at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:104)
at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:842)
at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:768)
at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:648)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:514)
at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:580)
at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:526)
at org.apache.log4j.LogManager.(LogManager.java:127)
at org.slf4j.impl.Log4jLoggerFactory.(Log4jLoggerFactory.java:66)
at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:72)
at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:45)
at org.apache.spark.internal.Logging$.org$apache$spark$internal$Logging$$isLog4j12(Logging.scala:222)
at org.apache.spark.internal.Logging.initializeLogging(Logging.scala:127)
at org.apache.spark.internal.Logging.initializeLogIfNecessary(Logging.scala:111)
at org.apache.spark.internal.Logging.initializeLogIfNecessary$(Logging.scala:105)
at org.apache.spark.deploy.SparkSubmit.initializeLogIfNecessary(SparkSubmit.scala:75)
at org.apache.spark.deploy.SparkSubmit.doSubmit(SparkSubmit.scala:83)
at org.apache.spark.deploy.SparkSubmit$$anon$2.doSubmit(SparkSubmit.scala:1007)
at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:1016)
at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
Caused by: java.lang.NullPointerException
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:418)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:357)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:383)
at org.fluentd.logger.sender.RawSocketSender.(RawSocketSender.java:34)
... 31 more

主要语言
Java
星标
210
派生
86
PR 合并指标
30 天内没有已合并 PR

环境准备

我们还没有检查这个项目的环境配置文件。先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

fluent/fluent-logger-java 的其他 Issue

查看 fluent/fluent-logger-java 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。