logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott Deboy <scott.de...@gmail.com>
Subject Re: I need to handle log4j:WARN Unrecognized element param
Date Fri, 15 Jul 2011 22:18:32 GMT
Here's how Chainsaw does it:

1. Create your own LoggerRepository implementation that implements
unrecognizedelementhandler (Chainsaw uses LoggerRepositoryExImpl from the
components companion).

    LogManager.setRepositorySelector(new RepositorySelector() {

      public LoggerRepository getLoggerRepository() {
          return repositoryExImpl;
      }}, repositorySelectorGuard);

Then you can call DOMConfigurator.configure and it'll pass those
unrecognized elements to your repository selector impl.

Scott

On Fri, Jul 15, 2011 at 3:02 PM, Turner, Jay
<Jay.Turner@sabre-holdings.com>wrote:

> I get "log4j:WARN Unrecognized element param" because we have some extra
> entries in the log4j 1.2.15 XML configuration file at the root level.
>
> The code uses
> DOMConfigurator configurator = new DOMConfigurator();
> configurator.doConfigure(inputStream,
> org.apache.log4j.LogManager.getLoggerRepository());
>
> The LoggerRepository returned doesn't implement UnrecognizedElementHandler
> (or at least not that I know how to connect to it).
> I thought of using
> class ExtendedLoggerRepository extends
> org.apache.log4j.LoggerRepositoryExImpl {
>                public boolean parseUnrecognizedElement(
>                        org.w3c.dom.Element element,
>                        java.util.Properties props)
>                        throws java.lang.Exception {
>                        // My code
>                }
>        }
>        configurator.doConfigure(
>                inputStream,
>                new
> ExtendedLoggerRepository(org.apache.log4j.LogManager.getLoggerRepository()));
>
> But my IntelliJ says that LoggerRepositoryExImpl, which is a public final
> class, is not in that package nor the spi subpackage.
>
> What is the right way of using the default logger repository but hooking in
> so that I can parse extra parameters as in:
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
> debug="true">
> <param name="somename" value="somevalue"/>
> :
>
> Thank you,
> Jay Turner
>
>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message