Log4j2 Custom appender: ERROR Attempted to append to non-started appender

一笑奈何 提交于 2020-01-30 05:00:35

问题


I have created a custom appender in log4j2. While using the custom appender, I am getting the following error: "ERROR Attempted to append to non-started appender". Any help is appreciated.


回答1:


Log4j 2 checks for each log event that the appender is in a useable state. The error you are seeing is that Log4j detects that the appender is not ready to be used.

Some appenders need to do preparation before they can be used. The start() lifecycle method is the place where appenders can do initialization. Log4j will not route events to an appender that is not in a STARTED state.

If your appender is added by configuration, Log4j will call the lifecycle method. If your appender extends AbstractAppender, this will update the state and should be sufficient. Otherwise take a look at the lifecycle state management in AbstractAppender.

If you configure in code you may need to call start() explicitly.



来源:https://stackoverflow.com/questions/39228697/log4j2-custom-appender-error-attempted-to-append-to-non-started-appender

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!