Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>AFAIK there's no "native" inheritance mechanism, but you may achieve the same result using an entity to reference and include an external xml fragment (see <a href="http://old.nabble.com/log4j-and-xlink-td21536915.html" rel="noreferrer" title="this nabble thread">this nabble thread</a>). If you just want to modify certain properties, a similar solution is described <a href="http://comments.gmane.org/gmane.comp.jakarta.log4j.user/19172" rel="noreferrer" title="here">here</a>. An Example using external entities:</p> <p>Main Config (log4j.xml):</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt; &lt;!DOCTYPE log4j:configuration SYSTEM "log4j.dtd" [ &lt;!ENTITY appender SYSTEM "appender.xml"&gt; &lt;!ENTITY root SYSTEM "root.xml"&gt; ]&gt; &lt;log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" &gt; &amp;appender; &amp;root; &lt;/log4j:configuration&gt; </code></pre> <p>appender.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;appender name="MyAppender" class="org.apache.log4j.DailyRollingFileAppender"&gt; &lt;param name="datePattern" value="'.'yyyy-MM-dd_HH-mm" /&gt; &lt;param name="file" value="logs/MyLogFile.log" /&gt; &lt;param name="Append" value="true" /&gt; &lt;layout class="org.apache.log4j.PatternLayout"&gt; &lt;param name="ConversionPattern" value="%d{ISO8601} %-5p [%t] %c: %m%n" /&gt; &lt;/layout&gt; &lt;/appender&gt; </code></pre> <p>root.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;root&gt; &lt;priority value="INFO" /&gt; &lt;appender-ref ref="MyAppender" /&gt; &lt;/root&gt; </code></pre> <p>It even works if both the root and the appender definition are placed into a <strong>single</strong> file, without the ?xml pi. So, the external content may even be an ill-formed xml fragment lacking a single root element. This allows for transferring the <strong>complete</strong> log4j config into an <strong>single external file</strong>:</p> <p>log4j.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt; &lt;!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"[ &lt;!ENTITY config SYSTEM "log4j-config.txt"&gt; ]&gt; &lt;log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" &gt; &amp;config; &lt;/log4j:configuration&gt; </code></pre> <p>log4j-config.txt:</p> <pre><code>&lt;appender name="MyAppender" class="org.apache.log4j.DailyRollingFileAppender"&gt; &lt;param name="datePattern" value="'.'yyyy-MM-dd_HH-mm" /&gt; &lt;param name="file" value="logs/MyLogFile.log" /&gt; &lt;param name="Append" value="true" /&gt; &lt;layout class="org.apache.log4j.PatternLayout"&gt; &lt;param name="ConversionPattern" value="%d{ISO8601} %-5p [%t] %c: %m%n" /&gt; &lt;/layout&gt; &lt;/appender&gt; &lt;root&gt; &lt;priority value="INFO" /&gt; &lt;appender-ref ref="MyAppender" /&gt; &lt;/root&gt; </code></pre> <p>If you need to adapt the log4j config in an individual and flexible way, you could try and merge the root.xml with the child.xml using XSLT or <a href="http://sourceforge.net/projects/el4j/" rel="noreferrer" title="XmlMerge &#40;part of el4j&#41;">XmlMerge (part of el4j)</a> to create a config on the fly, and feed the <a href="http://logging.apache.org/log4j/1.2/apidocs/index.html?org/apache/log4j/xml/DOMConfigurator.html" rel="noreferrer" title="org.apache.log4j.xml.DOMConfigurator">org.apache.log4j.xml.DOMConfigurator</a> with the resulting DOM. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload