It is looking like my issue was that because I’m adding the rootLogger to the 
configuration builder prior to adding the newAppenderRef so you cannot think of 
these as just object references. But rather steps with side affects that have 
to be performed in the correct order otherwise I guess you hit a terminal state 
where operations after that have no affect.

> On Mar 3, 2022, at 12:06 PM, Robert Nicholson <robert.nichol...@gmail.com> 
> wrote:
> 
> When I validate my config by using 
> configurationBuilder.writeXmlConfiguration(System.out)
> 
> I notice most is there but the Loggers don’t have the AppenderRef entries.
> 
> Why is that?
> 
> When debugging I can see that when I call something like
> 
> rootLogger.add(configurationBuilder.newAppenderRef(“appenderName”));
> 
> in the debugger under Logger I can see it has a Component with the 
> AppenderRef and the attributes of this ref match the name of the Appender
> that appears as an Appender in Appenders off the ConfigurationBuilder.
> 
> ie. the Loggers components has both the attribute “ref” -> “appenderName” and 
> the component is a AppenderRef pluginType
> 
> Why then does it choose to not include any AppenderRef for the logger in the 
> Xml it’s showing me?
> 
> This is what my code looks like
> 
> RootLoggerComponentBuilder rootLogger = 
> configurationBuilder.newRootLogger(Level.INFO);
> configurationBuilder.add(rootLogger);
> configurationBuilder.add(getAppender());
> rootLogger.add(configurationBuilder.newAppenderRef(“filelog”));
> 
> after this it will show a root logger in the XML with no AppenderRef
> 
> Similar for all other subsequent loggers.
> 


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

Reply via email to