开发者社区 > 云原生 > 正文

springboot集成log4j2 appender 日志发送失败

应用启动后,第一次可以正常发送日志,再次发送时报如下异常:

20210816 16:02:09.339 [main] INFO org.springframework.boot.actuate.endpoint.web.EndpointLinksResolver 58 - Exposing 1 endpoint(s) beneath base path '' 2021-08-16 16:02:09,478 main WARN SerializedLayout is deprecated due to the inherent security weakness in Java Serialization, see https://www.owasp.org/index.php/Deserialization_of_untrusted_data Consider using another layout, e.g. JsonLayout 20210816 16:02:09.495 [NettyClientSelector_1] INFO RocketmqRemoting 95 - closeChannel: close the connection to remote address[10.158.158.19:10911] result: true 2021-08-16 16:02:09,496 NettyClientSelector_1 ERROR Could not send message in RocketmqLog4j2Appender [rocketmqAppender].Message is : 2021-08-16 16:02:09,495 [INFO] RocketmqRemoting closeChannel: close the connection to remote address[10.158.158.19:10911] result: true org.apache.rocketmq.client.exception.MQClientException: The producer service state not OK, SHUTDOWN_ALREADY See http://rocketmq.apache.org/docs/faq/ for further details. at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.makeSureStateOK(DefaultMQProducerImpl.java:442) at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.sendDefaultImpl(DefaultMQProducerImpl.java:560) at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.sendOneway(DefaultMQProducerImpl.java:1014) at org.apache.rocketmq.client.producer.DefaultMQProducer.sendOneway(DefaultMQProducer.java:403) at org.apache.rocketmq.logappender.log4j2.RocketmqLog4j2Appender.append(RocketmqLog4j2Appender.java:106) at org.apache.logging.log4j.core.config.AppenderControl.tryCallAppender(AppenderControl.java:156) at org.apache.logging.log4j.core.config.AppenderControl.callAppender0(AppenderControl.java:129) at org.apache.logging.log4j.core.config.AppenderControl.callAppenderPreventRecursion(AppenderControl.java:120) at org.apache.logging.log4j.core.config.AppenderControl.callAppender(AppenderControl.java:84)

原提问者GitHub用户JerryZ521

展开
收起
芬奇福贵 2023-05-26 10:50:38 107 0
1 条回答
写回答
取消 提交回答
  • 这个问题解决了。 原因描述:ProducerInstancer每次获取producer都是同一个实例,而我们的场景需要动态更新log4j2配置,重新初始化上下文时关闭了producer,现在改成每次获取新对象,stop方法改成每次调用关闭当前appender中的producer对象。

    原回答者GitHub用户JerryZ521

    2023-05-26 17:15:11
    赞同 展开评论 打赏

阿里云拥有国内全面的云原生产品技术以及大规模的云原生应用实践,通过全面容器化、核心技术互联网化、应用 Serverless 化三大范式,助力制造业企业高效上云,实现系统稳定、应用敏捷智能。拥抱云原生,让创新无处不在。

热门讨论

热门文章

相关电子书

更多
PostgresChina2018_赖思超_PostgreSQL10_hash索引的WAL日志修改版final 立即下载
Kubernetes下日志实时采集、存储与计算实践 立即下载
日志数据采集与分析对接 立即下载