logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Curt Arnold <carn...@apache.org>
Subject svn commit: r500767 - in logging/log4j/trunk - bug 25106
Date Tue, 30 Jan 2007 23:24:02 GMT
r500767 | eross | 2007-01-28 03:43:30 -0600 (Sun, 28 Jan 2007) | 2 lines

Bug 25106 - Support XInclude in XML configuration scripts
Use reflection to attempt to call SAXParserFactory#setXIncludeAware 
(true)

Index: src/java/org/apache/log4j/joran/JoranConfigurator.java
===================================================================
18a19
 > import org.apache.log4j.Logger;
55a57
 > import java.lang.reflect.Method;
129a132,145
 >   private void setXIncludeAware(SAXParserFactory factory) {
 >     try {
 >       Class sig[] = new Class[] { boolean.class };
 >       Method m = factory.getClass().getMethod("setXIncludeAware",  
sig);
 >       m.invoke(factory, new Object[] { Boolean.TRUE });
 >     } catch (Exception e) {
 >       getLogger().debug("setXIncludeAware not supported");
 >     }
 >   }
 >
 >   private Logger getLogger() {
 >     return getLogger(repository);
 >   }
 >
142a159
 >         setXIncludeAware(spf);
146c163
<       getLogger(repository).error(errMsg, pce);
---
 >       getLogger().error(errMsg, pce);
157c174
<       getLogger(repository).error(errMsg, ie);
---
 >       getLogger().error(errMsg, ie);
161c178
<       getLogger(repository).error(errMsg, ex);
---
 >       getLogger().error(errMsg, ex);
174c191
<       getLogger(repository).debug("Finished parsing.");
---
 >       getLogger().debug("Finished parsing.");
Index: src/java/org/apache/log4j/joran/action/LoggerAction.java
===================================================================
102a103
 >       if (resourceBundle != null) {
106a108
 >       }
Index: tests/input/xml/xinclude2.xml
===================================================================
0a1,3
 > <logger name='foo'>
 > 	<level value='INFO'/>
 > </logger>
Index: tests/input/xml/xinclude.xml
===================================================================
0a1,12
 > <?xml version="1.0" encoding="UTF-8" ?>
 > <!DOCTYPE log4j:configuration>
 >
 > <log4j:configuration xmlns:log4j='http://logging.apache.org/'  
debug='true' reset='true' xmlns:xi="http://www.w3.org/2001/XInclude">
 >
 >   <xi:include href="xinclude2.xml"/>
 >
 >   <root>
 >     <level value="ALL" />
 >   </root>
 >
 > </log4j:configuration>
\ No newline at end of file
Index: tests/input/joran/resourceBundle.xml
===================================================================
0a1,21
 > <?xml version="1.0" encoding="UTF-8" ?>
 > <!DOCTYPE log4j:configuration>
 >
 > <log4j:configuration xmlns:log4j='http://logging.apache.org/'  
debug='true'>
 >
 >   <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
 >     <layout class="org.apache.log4j.PatternLayout">
 >       <param name="ConversionPattern"  value="%5sn %d %level [%t] % 
c - %m%n"/>
 >     </layout>
 >   </appender>
 >
 >   <logger name="foo" resourceBundle="L7D"/>
 >
 >   <logger name="bar" resourceBundle="NOT_HERE"/>
 >
 >   <root>
 >     <level value="DEBUG" />
 >     <appender-ref ref="CONSOLE" />
 >   </root>
 >
 > </log4j:configuration>
Index: tests/src/java/org/apache/log4j/joran/JoranConfiguratorTest.java
===================================================================
71c71
<     jc.doConfigure("tests/input/joran/simple2.xml",  
LogManager.getLoggerRepository());
---
 >     jc.doConfigure("./input/joran/simple2.xml",  
LogManager.getLoggerRepository());
85a86,93
 >   public void testXInclude() {
 >     jc.doConfigure("./input/xml/xinclude.xml",  
LogManager.getLoggerRepository());
 >     jc.dumpErrors();
 >     Logger l = Logger.getLogger("foo");
 >     assertEquals(Level.INFO, l.getLevel());
 >     System.out.println(jc.getExecutionContext().getErrorList());
 >   }
 >


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


Mime
View raw message