avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject cvs commit: avalon/logging/site/xdocs/impl/log4j index.xml
Date Sun, 29 Feb 2004 14:03:22 GMT
niclas      2004/02/29 06:03:22

  Modified:    logging/log4j/src/java/org/apache/avalon/logging/log4j
                        Log4JLoggingFactory.java
               logging/site/xdocs/impl/log4j index.xml
  Log:
  Added the ability to embedd Log4J configurations directly into Merlin's config.
  
  Revision  Changes    Path
  1.5       +22 -10    avalon/logging/log4j/src/java/org/apache/avalon/logging/log4j/Log4JLoggingFactory.java
  
  Index: Log4JLoggingFactory.java
  ===================================================================
  RCS file: /home/cvs/avalon/logging/log4j/src/java/org/apache/avalon/logging/log4j/Log4JLoggingFactory.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Log4JLoggingFactory.java	27 Feb 2004 22:39:35 -0000	1.4
  +++ Log4JLoggingFactory.java	29 Feb 2004 14:03:22 -0000	1.5
  @@ -30,6 +30,7 @@
   import org.apache.avalon.excalibur.i18n.Resources;
   
   import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.avalon.framework.configuration.ConfigurationUtil;
   
   import org.apache.avalon.logging.provider.LoggingCriteria;
   import org.apache.avalon.logging.provider.LoggingFactory;
  @@ -42,6 +43,8 @@
   import org.apache.log4j.PropertyConfigurator;
   import org.apache.log4j.xml.DOMConfigurator;
   
  +import org.w3c.dom.Element;
  +
   /**
    * A Log4J factory.
    *
  @@ -143,19 +146,28 @@
           m_BaseDirectory = criteria.getBaseDirectory();
   
           final Configuration config = criteria.getConfiguration();
  -        Configuration srcConf = config.getChild( "src" );
  -        Configuration updateConf = config.getChild( "update" );
  -        String src = srcConf.getValue();
  -        src = resolveSource( src );
  -        System.out.println( src );
  -        long updateInterval = updateConf.getValueAsLong( 0 );
  -        if( updateInterval > 0 )
  +        Configuration srcConf = config.getChild( "src", false );
  +        if( srcConf != null )
           {
  -            configureWithWatch( src, updateInterval );
  +            Configuration updateConf = config.getChild( "update" );
  +            String src = srcConf.getValue();
  +            src = resolveSource( src );
  +            System.out.println( src );
  +            long updateInterval = updateConf.getValueAsLong( 0 );
  +            if( updateInterval > 0 )
  +            {
  +                configureWithWatch( src, updateInterval );
  +            }
  +            else
  +            {
  +                configureWithOutWatch( src );
  +            }
           }
           else
           {
  -            configureWithOutWatch( src );
  +            Configuration log4jNode = config.getChild( "configuration" );
  +            Element node = ConfigUtil.toElement( log4jNode );
  +            DOMConfigurator.configure( node );
           }
           return new LoggingManagerImpl();
       }
  
  
  
  1.4       +42 -1     avalon/logging/site/xdocs/impl/log4j/index.xml
  
  Index: index.xml
  ===================================================================
  RCS file: /home/cvs/avalon/logging/site/xdocs/impl/log4j/index.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- index.xml	25 Feb 2004 15:57:17 -0000	1.3
  +++ index.xml	29 Feb 2004 14:03:22 -0000	1.4
  @@ -70,15 +70,56 @@
                 specified in milliseconds.
               </td>
             </tr>
  +          <tr>
  +            <td>configuration</td>
  +            <td>
  +              If you don't specify a &lt;src&gt; element, you MUST specifiy the
  +              complete Log4J configuration in this element. That mean that this
  +              &lt;configuration&gt; element corresponds to the root node of a
  +              Log4J configuration. See below for an example.
  +            </td>
  +          </tr>
           </table>
         </subsection>
  -      <subsection name="Example">
  +      <subsection name="Example - External Reference">
   <source><![CDATA[
       <logging>
         <src>conf/log4j.xml</src>
         <!-- Check for Update once every minute. -->
         <update>60000</update>
       </logging>
  +]]></source>
  +      </subsection>
  +      <subsection name="Example - Embedded Configuration">
  +<source><![CDATA[
  +<logging>
  +  <configuration>
  +    <appender name="FILE" class="org.apache.log4j.FileAppender">
  +      <param name="BufferedIO" value="true" />
  +      <param name="File" value="application.log" />
  +
  +      <layout class="org.apache.log4j.PatternLayout">
  +        <param name="ConversionPattern" value="%t %-5p %c{2} - %m%n"/>
  +      </layout>
  +    </appender>
  +
  +    <appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
  +      <layout class="org.apache.log4j.PatternLayout">
  +        <param name="ConversionPattern" value="%d %-5p [%t] %C{2} (%F:%L) - %m%n"/>
  +      </layout>
  +    </appender>
  +
  +    <category name="org.apache.avalon.merlin.activation">
  +      <priority value="debug"/>
  +      <appender-ref ref="STDOUT"/>
  +    </category>
  +
  +    <root>
  +      <priority value="error"/>
  +      <appender-ref ref="FILE"/>
  +    </root>
  +  </configuration>
  +</logging>
   ]]></source>
         </subsection>
       </section>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org


Mime
View raw message