You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Robert Nicholson <ro...@gmail.com> on 2022/03/02 22:55:39 UTC

Programmatic configuration all or nothing?

When using ConfigurationBuilder is it all or nothing or can you integrate what your builder builds into the existing log4j that’s already been initialized from log4j.xml. Actually I’ve already initialized using my xml “manually” using setConfigLocation earlier.

With 1.x you can get a reference an existing logger (already defined by log4j.xml) and then attach appenders to it.

That’s what I ideally want to do with ConfigurationBuilder so that I can still statically setup other loggers that don’t need to be dynamically created.


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Programmatic configuration all or nothing?

Posted by "Piotr P. Karwasz" <pi...@gmail.com>.
Hello Fred,

On Fri, Mar 11, 2022 at 1:29 AM Fred Eisele <fr...@gmail.com> wrote:
> I would like something similar.
> Maybe a way to initialize a builder with the current configuration?

An already initialized `AbstractConfiguration` can no longer be used
to initialize a configuration builder. However you can use a
CompositeConfiguration[1] to add your customization to the current
config.

Piotr

[1] https://logging.apache.org/log4j/2.x/log4j-core/apidocs/org/apache/logging/log4j/core/config/composite/CompositeConfiguration.html

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Programmatic configuration all or nothing?

Posted by Fred Eisele <fr...@gmail.com>.
I would like something similar.
Maybe a way to initialize a builder with the current configuration?

On Wed, Mar 2, 2022 at 11:14 PM Ralph Goers <ra...@dslextreme.com>
wrote:

> As its name implies, ConfigurationBuilder creates a new Configuration. Any
> Configuration you build this way would replace an existing Configuration.
>
> I’d like to understand your use case for wanting Programmatic
> configuration. If you need to do that either we need to implement some
> feature so you don’t have to or you aren’t aware that you already don’t.
>
> To be clear, with Log4j 2 you wouldn’t be creating Loggers, you would be
> creating LoggerConfigs and attaching appenders to them. Yes, this can be
> done programmatically but we generally try to discourage it.
>
> Ralph
>
> > On Mar 2, 2022, at 3:55 PM, Robert Nicholson <ro...@gmail.com>
> wrote:
> >
> > When using ConfigurationBuilder is it all or nothing or can you
> integrate what your builder builds into the existing log4j that’s already
> been initialized from log4j.xml. Actually I’ve already initialized using my
> xml “manually” using setConfigLocation earlier.
> >
> > With 1.x you can get a reference an existing logger (already defined by
> log4j.xml) and then attach appenders to it.
> >
> > That’s what I ideally want to do with ConfigurationBuilder so that I can
> still statically setup other loggers that don’t need to be dynamically
> created.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> > For additional commands, e-mail: log4j-user-help@logging.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>

Re: Programmatic configuration all or nothing?

Posted by Ralph Goers <ra...@dslextreme.com>.
As its name implies, ConfigurationBuilder creates a new Configuration. Any Configuration you build this way would replace an existing Configuration. 

I’d like to understand your use case for wanting Programmatic configuration. If you need to do that either we need to implement some feature so you don’t have to or you aren’t aware that you already don’t. 

To be clear, with Log4j 2 you wouldn’t be creating Loggers, you would be creating LoggerConfigs and attaching appenders to them. Yes, this can be done programmatically but we generally try to discourage it.

Ralph

> On Mar 2, 2022, at 3:55 PM, Robert Nicholson <ro...@gmail.com> wrote:
> 
> When using ConfigurationBuilder is it all or nothing or can you integrate what your builder builds into the existing log4j that’s already been initialized from log4j.xml. Actually I’ve already initialized using my xml “manually” using setConfigLocation earlier.
> 
> With 1.x you can get a reference an existing logger (already defined by log4j.xml) and then attach appenders to it.
> 
> That’s what I ideally want to do with ConfigurationBuilder so that I can still statically setup other loggers that don’t need to be dynamically created.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org