logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Gregory <garydgreg...@gmail.com>
Subject Re: Tying up loose ends with AbstractConfiguration.AbstractConfiguration(LoggerContext, ConfigurationSource)
Date Fri, 26 Aug 2016 17:25:10 GMT
On Thu, Aug 25, 2016 at 9:58 PM, Ralph Goers <ralph.goers@dslextreme.com>
wrote:

> CompositeConfiguration doesn’t look correct to me. It makes sense for it
> to have a null source, but I’m not sure why it should have a null
> LoggerContext.I think it should be:
>
> super(configurations.get(0).getLoggerContext(), ConfigurationSource.NULL_
> SOURCE);
>

Done in Git master. Thank you for the tip.

Gary


>
> Either that or getLoggerContext() should do that.
>
> Ralph
>
> On Aug 25, 2016, at 9:03 PM, Gary Gregory <garydgregory@gmail.com> wrote:
>
> [oops, sent too soon]
>
> Hi All:
>
> I'd like to tie up a loose end with callers of
> AbstractConfiguration.AbstractConfiguration(LoggerContext,
> ConfigurationSource)
>
> There are four call sites that do this:
>
> super(null, ConfigurationSource.NULL_SOURCE);
>
> These are:
> - org.apache.logging.log4j.core.BasicConfigurationFactory.
> BasicConfiguration.BasicConfiguration()
> - org.apache.logging.log4j.core.config.DefaultConfiguration.
> DefaultConfiguration()
> - org.apache.logging.log4j.core.config.NullConfiguration.
> NullConfiguration()
> - org.apache.logging.log4j.core.config.composite.CompositeConfiguration.CompositeConfiguration(List<?
> extends AbstractConfiguration>)
>
> I am worried about this last one.
>
> So I cannot null check the logger context in the AbstractConfiguration
> ctor:
>
>     protected AbstractConfiguration(LoggerContext loggerContext, final
> ConfigurationSource configurationSource) {
>         this.loggerContext = new WeakReference<>(loggerContext);
>         // The loggerContext is null for the NullConfiguration class.
>         // this.loggerContext = new WeakReference(Objects.requireNonNull(loggerContext,
> "loggerContext is null"));
>         this.configurationSource = Objects.requireNonNull(configurationSource,
> "configurationSource is null");
>         ...
>     }
>
> There are a couple of call sites where we could pass in a LC but we'd need
> to add the LC to ctor for classes listed above. The default configs usually
> include just console logging, but is that straight to the console or via a
> ConsoleAppender?
>
> I could even see adding a ctor AbstractConfiguration.Abstract
> Configuration(NullConfiguration) to make it obvious that this is the only
> way is OK to pass null for the logger context. Then the NullConfiguration
> ctor does not need to pass null.
>
> Thoughts?
>
> Gary
>
> ---------- Forwarded message ----------
> From: Gary Gregory <garydgregory@gmail.com>
> Date: Thu, Aug 25, 2016 at 8:54 PM
> Subject: Tying up loose ends with AbstractConfiguration.
> AbstractConfiguration(LoggerContext, ConfigurationSource)
> To: Log4J Developers List <log4j-dev@logging.apache.org>
>
>
> Hi All:
>
> I'd like to tied up some loose end with Tying up loose ends with
> AbstractConfiguration.AbstractConfiguration(LoggerContext,
> ConfigurationSource)
>
> There are three call sites that do this:
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>
>
>


-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Mime
View raw message