logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thainan Frota <hada...@gmail.com>
Subject Re: Log4j2 error on load XML configuration file
Date Wed, 13 Feb 2013 11:34:54 GMT
I tried, but could not.

Could you please send an example?


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


2013/2/13 Ralph Goers <ralph.goers@dslextreme.com>

> 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 <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
>
>
>

Mime
View raw message