Re: LoggerStore
Mauro Talevi <[email protected]>
| Newsgroups | gmane.comp.java.spice.devel |
|---|---|
| Message-ID | <[email protected]> |
Peter Donald wrote:
>
>
> I am still not entirely sure what you mean. What I mean is changing to
> something like
>
> public class Log4JLoggerStoreFactory
> implements LoggerStoreFactory
> {
> public LoggerStore createLoggerStore( final Map config )
> throws Exception
> {
> InputStream resource = (InputStream)config.get( CONFIGURATION );
> if( resource != null )
> {
> String type = (String)config.get( CONFIGURATION_TYPE );
> if( type != null )
> {
> if( type.equals( LoggerStoreFactory.PROPERTIES ) )
> {
> return new Log4jLoggerStore( buildProperties( resource ) );
> }
> else if( type.equals( LoggerStoreFactory.XML ) )
> {
> return new Log4jLoggerStore( buildElement( resource ) );
> }
> }
> }
> throw new Exception( "Invalid configuration" );
> }
> }
>
> public class Log4JLoggerStore
> extends AbstractLoggerStore
> {
> public Log4JLoggerStore( final Element element )
> throws Exception
> {
> m_repository = LogManager.getLoggerRepository();
> final DOMConfigurator configurator = new DOMConfigurator();
> configurator.doConfigure( element, repository );
> setRootLogger( new Log4JLogger( m_repository.getRootLogger() ) );
> }
>
> public Log4JLoggerStore( final Properties properties )
> throws Exception
> {
> m_repository = LogManager.getLoggerRepository();
> final PropertyConfigurator configurator = new PropertyConfigurator();
> configurator.doConfigure( properties, repository );
> setRootLogger( new Log4JLogger( m_repository.getRootLogger() ) );
> }
> ...
> }
>
> AFAIK this is just moving code around and should not make things any harder?
>
>
actually, this is how I originally had it, but I opted to have a
constructor with an InputStream and let the LoggerStore implementation
deal with it.
One reason is that JDK14 requires Properties AS InputStream and I
thought it would lead to confusion with the other Loggers.
Other reason is that Log4J XML config did not seem to work properly on
JDK1.4 - I think because the Element was missing the DOCUMENTTYPE bit.
There is an email from Ceki on the log4j list which I need to dig up.
So - once this issue is solved - I agree it is a matter of style.
Are you saying that there are configuration which may not come from an
InputStream? If so can you provide an example?
I seems that most loggers are more likely to accept an InputStream.
But I'm not bothered to go back to the original version.
Cheers
-------------------------------------------------------
Enterprise Linux Forum Conference & Expo, June 4-6, 2003, Santa Clara
The only event dedicated to issues related to Linux enterprise solutions
www.enterpriselinuxforum.com