Skip to content

Handling Fallback for Custom LogEventFactory #1798

Closed Answered by ppkarwasz
skjelmo asked this question in Q&A
Discussion options

You must be logged in to vote

@skjelmo,

Yes, even if the error message fails to mention it, Log4j Core falls back to a default log event factory, if your custom factory is not available (cf. source code).

If you want to prevent the message from appearing, you can bundle your custom LogEventFactory together with a log4j2.component.properties containing:

log4j2.logEventFactory = fully_qualified_name_of_your_class

Remark: a custom LogEventFactory is not necessarily the best tool for the job, since it can not split events. You can split events with a custom Appender implementation or you can limit the size of the stacktrace (each layout has a way to limit stacktraces).

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by skjelmo
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants