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 Gulcu <cg...@urbanet.ch> on 2001/01/17 14:25:36 UTC
log4j: namespace?
Hello,
I am about to add the log4j: prefix to configuration elements in log4j.dtd
and the associated DOMConfigurator. My question is whether to add the
"log4j:" prefix to all log4j elements or just to the configuration element.
The typical log4j XML config file looks like:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration SYSTEM "log4j.dtd">
<configuration>
<appender name="A1" class="org.apache.log4j.FileAppender">
<param name="File" value="temp.A1" />
<param name="Append" value="false" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p %c{2} - %m\n"/>
</layout>
</appender>
<root>
<priority value ="debug" />
<appender-ref ref="A1" />
</root>
</configuration>
If we only added the log4j: prefix to configuration element, the same
config file would read as:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration SYSTEM "log4j.dtd">
<log4j:configuration>
<appender name="A1" class="org.apache.log4j.FileAppender">
<param name="File" value="temp.A1" />
<param name="Append" value="false" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p %c{2} - %m\n"/>
</layout>
</appender>
<root>
<priority value ="debug" />
<appender-ref ref="A1" />
</root>
</log4j:configuration>
Is that enough? Or should we add a prefix to all elements? The config file
would look as:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration SYSTEM "log4j.dtd">
<log4j:configuration>
<log4j:appender name="A1" class="org.apache.log4j.FileAppender">
<log4j:param name="File" value="temp.A1" />
<log4j:param name="Append" value="false" />
<log4j:layout class="org.apache.log4j.PatternLayout">
<log4j:param name="ConversionPattern" value="%-5p %c{2} -
%m\n"/>
</log4j:layout>
</log4j:appender>
<log4j:root>
<log4j:priority value ="debug" />
<log4j:appender-ref ref="A1" />
</log4j:root>
</log4j:configuration>
What is considered best practice? Thanks for your help. Ceki
---
Freedom as in the capacity to exercise choice.
Re: log4j: namespace?
Posted by Endre Stølsvik <En...@Stolsvik.com>.
| What is considered best practice? Thanks for your help. Ceki
I'm not sure about best practice, but the last example (log4j: all over
the place) sure looks ugly to me!
;)
--
Mvh,
Endre