Re: log4j2 2.14.0 and the mongodb4 appender

Gary Gregory <[email protected]>
Newsgroups gmane.comp.jakarta.log4j.user
Message-ID <CACZkXPy8nitK+HYRfQ_vUn8Yb9hRZkwngr2j8EJKn2bMPAT7rA@mail.gmail.com>
Hello Julian,

When I created the version 4 of the MongoDB appender, I realized that for
all the use cases I had and I felt were reasonable, I could use a
connection string, a bit like you can in JDBC, which I could not do with a
version 3 driver. There are two settings IIRC that I did not find mappings
in a version 4 connection string: capped and collection size.

Note that you can also parameterize the configuration with ${variables}, so
you could parameterize the user and password in a connection string, see:

-
https://logging.apache.org/log4j/2.x/manual/configuration.html#RuntimeLookup
-
https://logging.apache.org/log4j/2.x/manual/configuration.html#PropertySubstitution
-
https://logging.apache.org/log4j/2.x/manual/appenders.html#NoSQLAppenderMongoDB4

If you feel like you still need the factory method as a mechanism to create
a provider, then please feel free to provide a PR on GitHub here:
https://github.com/apache/logging-log4j2

Gary

On Mon, Nov 30, 2020 at 10:17 AM Julian Woodward <[email protected]> wrote:

> When the mongodb4 appender was created for log4j2, the ability to specify a
> factory class/method in the log4j2.xml file was removed, and the
> configuration option was instead reverted to requiring a simple connection
> string.
>
> Was there a technical reason why that needed to happen, or was it just for
> simplicity at dev time?
>
> I've been relying on the factory approach, as the database credentials are
> not known until run-time in my use-case. I was also looking forward to
> having a mongodb4 version to upgrade to, but as it stands now this is
> unfortunately not giving me what I need.
>
> Thanks!
>
> Julian Woodward
>
> PS New to this forum, so please be forgiving of any breaches of etiquette!
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.