Yes I did. XmlConfigurationFactory has an order value of 5. @Plugin( name="confplugin", category = "ConfigurationFactory") @Order(6)
public class CustomConfigurationFactory extends ConfigurationFactory{ @Override public Configuration getConfiguration(final LoggerContext loggercontext, final ConfigurationSource confsource){ return new CustomConfiguration(loggercontext,confsource); } @Override public String[] getSupportedTypes(){ return new String[] {"*",".xml"}; } } On Fri, Dec 13, 2019 at 11:35 AM Ralph Goers <ralph.go...@dslextreme.com> wrote: > Did you also create a CustomConfigurationFactory with an Order value that > is larger than the value in XmlConfigurationFactory? > > Ralph > > > On Dec 13, 2019, at 11:46 AM, Lohith BK <lohi...@gmail.com> wrote: > > > > Greetings, > > > > I have been trying to get the programmatic configuration working (on top > of > > the file based configuration), but it doesn't seem to merge them > together. > > Here is the meat of the plugin code. > > /tmp/xpose.log gets created, and also the output from the programmatic > > configuration /tmp/customconfig.xml gets created and looks as expected. > > However when I try to get the configured logger in the code it appears > use > > the ones inherited from the root logger. Also, the example code in the > > documentation doesn't seem to reflect the newer builder API. > > > > https://logging.apache.org/log4j/2.x/manual/customconfig.html > > > > > > class CustomConfiguration extends XmlConfiguration{ > > public CustomConfiguration(final LoggerContext loggercontext, final > > ConfigurationSource confsource){ > > super(loggercontext,confsource); > > } > > @Override > > protected void doConfigure(){ > > super.doConfigure(); > > > > ConfigurationBuilder<BuiltConfiguration> builder = > > ConfigurationBuilderFactory.newConfigurationBuilder(); > > AppenderComponentBuilder apbuilder = > > > builder.newAppender("XPOSE","File").addAttribute("fileName","/tmp/xpose.log"); > > builder.add(apbuilder); > > LoggerComponentBuilder lgbuilder = > > > builder.newLogger("customlogger",Level.INFO).addAttribute("additivity","false"); > > lgbuilder.add(builder.newAppenderRef("XPOSE")); > > builder.add(lgbuilder); > > > > try{ > > File opt = new File("/tmp/customconfig.xml"); > > FileOutputStream fop = new FileOutputStream(opt); > > builder.writeXmlConfiguration(fop); > > builder.build(); > > }catch(FileNotFoundException e){ > > System.out.println(e.getMessage()); > > }catch(IOException e){ > > System.out.println(e.getMessage()); > > } > > } > > } > > > > Output of programmatic configuration. > > > > <?xml version="1.0" ?> > > <Configuration> > > <Appenders> > > <File name="XPOSE" fileName="/tmp/xpose.log"/> > > </Appenders> > > <Loggers> > > <Logger name="customlogger" level="INFO" additivity="false"> > > <AppenderRef ref="XPOSE"/> > > </Logger> > > </Loggers> > > </Configuration> > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org > For additional commands, e-mail: log4j-user-h...@logging.apache.org > >