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 Thainan Frota <ha...@gmail.com> on 2013/02/14 01:25:54 UTC

Log4j2 error on load XML configuration file

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 <http://linkedin.com/in/thainanfrota>
Facebook: thainanfrota <http://facebook.com/thainanfrota>
Twitter: @thainanfrota <http://twitter.com/thainanfrota>
Telefone: +55 75 9141 0429 | E-mail: thainanfrota@gmail.com