Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to configure a ContextDataProvider for a specified Appender? #1377

Closed
a11enhuang opened this issue Mar 17, 2023 · 1 comment
Closed

How to configure a ContextDataProvider for a specified Appender? #1377

a11enhuang opened this issue Mar 17, 2023 · 1 comment

Comments

@a11enhuang
Copy link

I have a custom Appender and want to configure a specific ContextDataProvider for this Appender, how can I do it? After reading the documentation and code, I found that ContextDataProvider is loaded through SPI, which means that once I load it through SPI, it will work for all Appenders, but I only want a certain Appender to take effect.
I tried specifying a ContextDataProvider in the config file:

<LogCollector name="MyAppender">
    <ContextDataProvider class="com.xxx.MyContextDataProvider"/>
    <PatternLayout pattern="${CONSOLE_LOG_PATTERN}" charset="UTF-8"/>
</LogCollector>

Then I got an error:
ERROR StatusConsoleListener MyAppender contains an invalid element or attribute "ContextDataProvider"
what should I do?
The version of log4j I am using is v2.20

@ppkarwasz
Copy link
Contributor

ppkarwasz commented Mar 17, 2023

The question template states:

As clearly indicated in the Log4j support page, please use mailing lists for questions!
Issues asking questions will be removed, and you will be asked to post questions to the mailing lists instead.

So please post on the log4j-user@logging.apache.org mailing list or ask a question on StackOverlow using the log4j2 tag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants