logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Turner, Jay" <Jay.Tur...@sabre-holdings.com>
Subject RE: I need to handle log4j:WARN Unrecognized element param
Date Fri, 15 Jul 2011 23:25:08 GMT
Thank you. This lets me put my own LoggerRepository in as the default. But how do I create
my LoggerRepository that does the same things as the default LoggerRepository, but includes
the UnrecognizedElementHandler? Does this?
	public LoggerRepository() implements UnrecognizedElementHandler {
		public parseUnrecognizedElement(...) { ... }
	}
Does the implemented class do everything the default does though I haven't overridden methods?

Thank you,
Jay Turner


-----Original Message-----
From: Scott Deboy [mailto:scott.deboy@gmail.com] 
Sent: Friday, July 15, 2011 5:19 PM
To: Log4J Users List
Subject: Re: I need to handle log4j:WARN Unrecognized element param

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

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Mime
View raw message