You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by jh...@apache.org on 2018/01/23 13:25:36 UTC
ant git commit: document how to use the Log4j 1.2 Bridge
Repository: ant
Updated Branches:
refs/heads/master 610b0b641 -> 6d42415d9
document how to use the Log4j 1.2 Bridge
Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/6d42415d
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/6d42415d
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/6d42415d
Branch: refs/heads/master
Commit: 6d42415d95b2a8c920b0dd6206bff2bbaa63a2cb
Parents: 610b0b6
Author: Jan Matèrne <jh...@apache.org>
Authored: Tue Jan 23 14:25:19 2018 +0100
Committer: Jan Matèrne <jh...@apache.org>
Committed: Tue Jan 23 14:25:19 2018 +0100
----------------------------------------------------------------------
manual/listeners.html | 39 +++++++++++++++++++++++++++++++++++++--
1 file changed, 37 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant/blob/6d42415d/manual/listeners.html
----------------------------------------------------------------------
diff --git a/manual/listeners.html b/manual/listeners.html
index bbb03e0..e201638 100644
--- a/manual/listeners.html
+++ b/manual/listeners.html
@@ -418,6 +418,41 @@ log4j.appender.LogFile.file=build.log
<p>For more information about configuring Log4J see <a href="http://logging.apache.org/log4j/docs/documentation.html">its
documentation page</a>.</p>
+<h4>Using the Log4j 1.2 Bridge</h4>
+You could use the <a href="http://logging.apache.org/log4j/2.x/log4j-1.2-api/index.html">Log4j Bridge</a>
+if your application is written against the Log4j (1.x) API, but you want to use the Log4j 2.x runtime.
+For using the bridge with Ant you have to add
+<ul>
+ <li>log4j-1.2-api-${log4j.version}.jar</li>
+ <li>log4j-api-${log4j.version}.jar</li>
+ <li>log4j-core-${log4j.version}.jar</li>
+ <li>log4j2.xml</li>
+</ul>
+to your classpath (e.g. via the <code>-lib</code> option).
+Translating the 1.x properties file into the 2.x xml syntax would result in
+<blockquote>
+<pre><code><?xml version="1.0" encoding="UTF-8"?>
+<Configuration status="WARN">
+ <Appenders>
+ <File name="file" fileName="build.log">
+ <PatternLayout>
+ <Pattern>[%6r] %8c{1} : %m%n</Pattern>
+ </PatternLayout>
+ </File>
+ </Appenders>
+ <Loggers>
+ <Root level="ERROR">
+ <AppenderRef ref="file" level="DEBUG"/>
+ </Root>
+ <Logger name="org.apache.tools.ant.Project" level="INFO"/>
+ <Logger name="org.apache.tools.ant.Project" level="INFO"/>
+ <Logger name="org.apache.tools.ant.taskdefs" level="INFO"/>
+ <Logger name="org.apache.tools.ant.taskdefs.Echo" level="WARN"/>
+ </Loggers>
+</Configuration>
+</code></pre>
+</blockquote>
+
<h3><a name="XmlLogger">XmlLogger</a></h3>
@@ -605,7 +640,7 @@ developers.</p>
<ul>
<li>
- A listener or logger should not write to standard output or error in the <code>messageLogged() method</code>;
+ A listener or logger should not write to standard output or error in the <code>messageLogged()</code> method;
Ant captures these internally and it will trigger an infinite loop.
</li>
<li>
@@ -613,7 +648,7 @@ developers.</p>
the output is processed. Slow logging means a slow build.
</li>
<li>When a build is started, and <code>BuildListener.buildStarted(BuildEvent event)</code> is called,
- the project is not fully functional. The build has started, yes, and the event.getProject() method call
+ the project is not fully functional. The build has started, yes, and the <code>event.getProject()</code> method call
returns the Project instance, but that project is initialized with JVM and ant properties, nor has it
parsed the build file yet. You cannot call <code>Project.getProperty()</code> for property lookup, or
<code>Project.getName()</code> to get the project name (it will return null).