Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is "xmlns:log4j" a required attribute of the <log4j:configuration> tag?

I see a bunch of sample log4j configurations that contain xmlns:log4j="http://jakarta.apache.org/log4j/" in the <log4j:configuration> tag, is this attribute required? What does having this attribute in my configuration do for me?

Example:

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
    <appender name="infoLogsFile" class="org.apache.log4j.RollingFileAppender">
        <param name="File" value="MyApplication.log"/>     
        <layout class="org.apache.log4j.PatternLayout"> 
            <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
        </layout>
    </appender>
    <root> 
        <priority value ="DEBUG" /> 
        <appender-ref ref="infoLogsFile"/>
    </root>
</log4j:configuration>

Could I do this instead?

<log4j:configuration>
    <appender name="infoLogsFile" class="org.apache.log4j.RollingFileAppender">
        <param name="File" value="MyApplication.log"/>     
        <layout class="org.apache.log4j.PatternLayout"> 
            <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
        </layout>
    </appender>
    <root> 
        <priority value ="DEBUG" /> 
        <appender-ref ref="infoLogsFile"/>
    </root>
</log4j:configuration>
like image 964
Mike Rylander Avatar asked Dec 21 '12 20:12

Mike Rylander


People also ask

What are the three most important components of log4j?

log4j has three main components: loggers: Responsible for capturing logging information. appenders: Responsible for publishing logging information to various preferred destinations. layouts: Responsible for formatting logging information in different styles.

What is log4j default configuration?

Log4j will provide a default configuration if it cannot locate a configuration file. The default configuration, provided in the DefaultConfiguration class, will set up: A ConsoleAppender attached to the root logger.


1 Answers

The xmlns attribute specifies that elements prepended with log4j are defined by the schema referenced by that URL. Log4J does not actually perform schema validation before attempting to parse the configuration file, so it is not actually required.

like image 77
Thorn G Avatar answered Oct 19 '22 23:10

Thorn G