Can you use the Configurator class?
Ralph
On Feb 12, 2013, at 7:16 PM, Thainan Frota wrote:
> I'm trying to use an XML configuration file for Log4j2 that is embedded in my
> Java application, but is not working.
>
> The code:
>
> ConfigurationSource source = new
> ConfigurationSource(Main.class.getResourceAsStream("/in/gunbound/prelauncher/server/log4j2/log4j2.xml"));
> ConfigurationFactory factory = (ConfigurationFactory)
> XMLConfigurationFactory.getInstance().getConfiguration(source);
> ConfigurationFactory.setConfigurationFactory(factory);
>
> The error:
>
> > Exception in thread "main" java.lang.ClassCastException:
> > org.apache.logging.log4j.core.config.XMLConfiguration cannot be cast
> > to org.apache.logging.log4j.core.config.ConfigurationFactory at
> > in.gunbound.prelauncher.server.Main.main(Main.java:62)
>
> Can anyone help me please?
>
> Note. The xml file is within my JAR, ie, I created a package to store it
> because I do not want the settings file log4j2 is exposed to the user.
>
> Atenciosamente,
>
> --
> Thainan Frota
> LinkedIn: thainanfrota
> Facebook: thainanfrota
> Twitter: @thainanfrota
> Telefone: +55 75 9141 0429 | E-mail: [email protected]