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

Missing setter for connectionStringSource in MongoDb4Provider #1389

Closed
ihordz opened this issue Mar 24, 2023 · 2 comments · Fixed by #1390
Closed

Missing setter for connectionStringSource in MongoDb4Provider #1389

ihordz opened this issue Mar 24, 2023 · 2 comments · Fixed by #1390
Assignees
Milestone

Comments

@ihordz
Copy link
Contributor

ihordz commented Mar 24, 2023

Description

It's no way to create MongoDb4Provider programmatically. Setter for connectionStringSource is missing in Builder.

Configuration

Version: 2.14.0+ (From the first version when MongoDB 4 support was added)

@ihordz ihordz changed the title Missing setter for connectionStringSource on MongoDb4Provider Missing setter for connectionStringSource in MongoDb4Provider Mar 24, 2023
ihordz added a commit to ihordz/logging-log4j2 that referenced this issue Mar 24, 2023
ihordz added a commit to ihordz/logging-log4j2 that referenced this issue Mar 24, 2023
@vy vy self-assigned this Mar 25, 2023
@vy vy added this to the 2.21.0 milestone Mar 25, 2023
@vy
Copy link
Member

vy commented Mar 25, 2023

Thanks so much for the report and the PR @ihordz, much appreciated! I will merge them momentarily.

You are both right and wrong. You're right that MongoDb4Provider indeed doesn't expose connectionStringSource in its builder. That said, you don't (and shouldn't!) need that for programmatic configuration. You shouldn't be using the MongoDb4Provider class directly, but rather be accessing it via AppenderComponentBuilder. See the programmatic configuration guide for details.

As a matter of fact, by accessing the classes directly rather than using the configuration API, you are walking on thin ice. Log4j crew strives to provide backward compatibility at the API (i.e., log4j-api) and configuration level, though we are not that strict when it comes to the implementation (i.e., log4j-core) itself. Hence, I strongly advise you to always stick to the configuration API for programmatic configuration.

@vy vy closed this as completed in #1390 Mar 25, 2023
@ihordz
Copy link
Contributor Author

ihordz commented Mar 25, 2023

Thank you @vy for quick merge and good advice.

@ppkarwasz ppkarwasz modified the milestones: 2.21.0, 2.20.1 Aug 1, 2023
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

Successfully merging a pull request may close this issue.

3 participants