You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Ceki Gülcü <ce...@qos.ch> on 2004/12/29 00:27:52 UTC

Recent architectural enhacements

Hello all,

I recently made two small architectural enhacements.

1) LoggerRepository now also acts as a storage for various objects
used by log4j components. Components can access this storage with the
LoggerRepository.getObject(key) and LoggerRepository.setObject(key,
value) methods.

2) Appender and Layout instances now keep track of the
LoggerRepository they are attached to. JoranConfigurator and
PropertyConfigurator will invoke the setLoggerRepository() methods of
an Appender or Layout when it instanciates one.

Use case:

New conversion words can be easily added to PatternLayout using
configuration files. These conversion words will be shared by all
instances of PatternLayout.

For example you can write:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration>

<configuration xmlns="http://logging.apache.org/">

   <!-- teach log4j a new conversion word -->
   <conversionRule conversionWord="counter" 
converterClass="pattern.CountingPatternConverter"/>

   <!-- the new conversion word is available for immediate use -->
   <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
     <layout class="org.apache.log4j.PatternLayout">
       <param name="ConversionPattern" value="[%3.10counter] - %m%n"/>
     </layout>
   </appender>

   <root>
    <appender-ref ref="CONSOLE"/>
   </root>
</configuration>

See $LOG4J_HOME/examples/src/pattern/ directory for more details.


-- 
Ceki Gülcü

   The complete log4j manual: http://www.qos.ch/log4j/



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


Re: Recent architectural enhacements

Posted by Ceki Gülcü <ce...@qos.ch>.

BTW, all tests run successfully. Moreover, the ./tests/ and
./examples/ have been totally decoupled which should solve at least
some of the problems encountered by both Jake and Curt when running
the test cases.

At 12:27 AM 12/29/2004, Ceki Gülcü wrote:

>Hello all,
>
>I recently made two small architectural enhacements.
>
>1) LoggerRepository now also acts as a storage for various objects
>used by log4j components. Components can access this storage with the
>LoggerRepository.getObject(key) and LoggerRepository.setObject(key,
>value) methods.
>
>2) Appender and Layout instances now keep track of the
>LoggerRepository they are attached to. JoranConfigurator and
>PropertyConfigurator will invoke the setLoggerRepository() methods of
>an Appender or Layout when it instanciates one.
>
>Use case:
>
>New conversion words can be easily added to PatternLayout using
>configuration files. These conversion words will be shared by all
>instances of PatternLayout.
>
>For example you can write:
>
><?xml version="1.0" encoding="UTF-8" ?>
><!DOCTYPE configuration>
>
><configuration xmlns="http://logging.apache.org/">
>
>   <!-- teach log4j a new conversion word -->
>   <conversionRule conversionWord="counter" 
> converterClass="pattern.CountingPatternConverter"/>
>
>   <!-- the new conversion word is available for immediate use -->
>   <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
>     <layout class="org.apache.log4j.PatternLayout">
>       <param name="ConversionPattern" value="[%3.10counter] - %m%n"/>
>     </layout>
>   </appender>
>
>   <root>
>    <appender-ref ref="CONSOLE"/>
>   </root>
></configuration>
>
>See $LOG4J_HOME/examples/src/pattern/ directory for more details.
>
>
>--
>Ceki Gülcü
>
>   The complete log4j manual: http://www.qos.ch/log4j/
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
>For additional commands, e-mail: log4j-dev-help@logging.apache.org

-- 
Ceki Gülcü

   The complete log4j manual: http://www.qos.ch/log4j/



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