﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-Pudgy's World-随笔分类-Log4j</title><link>http://www.blogjava.net/Pudgy/category/2851.html</link><description>&lt;SCRIPT&gt;
var dict_width   = 'auto'
var dict_height  = '72px'
var dict_background = 'transparent'
var dict_border  = '0px dotted #000000'
var dict_textColor = '#6FBC4C'
var dict_fontSize = '100%'
var dict_encoding = 'Utf-8'
&lt;/SCRIPT&gt;
&lt;SCRIPT src="http://livid.cn/services/fortune"&gt;&lt;/SCRIPT&gt;
&lt;script src="http://www.google-analytics.com/urchin.js" type="text/javascript"&gt;
&lt;/script&gt;</description><language>zh-cn</language><lastBuildDate>Tue, 27 Feb 2007 12:05:26 GMT</lastBuildDate><pubDate>Tue, 27 Feb 2007 12:05:26 GMT</pubDate><ttl>60</ttl><item><title>log4j Tutorials</title><link>http://www.blogjava.net/Pudgy/archive/2005/08/18/10449.html</link><dc:creator>Pudgy's World</dc:creator><author>Pudgy's World</author><pubDate>Thu, 18 Aug 2005 08:58:00 GMT</pubDate><guid>http://www.blogjava.net/Pudgy/archive/2005/08/18/10449.html</guid><wfw:comment>http://www.blogjava.net/Pudgy/comments/10449.html</wfw:comment><comments>http://www.blogjava.net/Pudgy/archive/2005/08/18/10449.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/Pudgy/comments/commentRss/10449.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Pudgy/services/trackbacks/10449.html</trackback:ping><description><![CDATA[<font size="2"><span style="font-family: verdana;" id="ArticleContent1_ArticleContent1_lblContent"><p class="toc" xmlns="http://www.w3.org/1999/xhtml"><b>目录</b></p>
<div class="toc" xmlns="http://www.w3.org/1999/xhtml">
<dl><dt>1. <a href="http://www.csdn.net/editor/data.asp?text=21291#LOG4J-Introduction">简介</a> 
</dt><dt>2. <a href="http://www.csdn.net/editor/data.asp?text=21291#LOG4J-Installation">安装</a> 
</dt><dt>3. <a href="http://www.csdn.net/editor/data.asp?text=21291#LOG4J-Basics">log4j基本概念</a> 
</dt><dd>
<dl><dt>3.1. <a href="http://www.csdn.net/editor/data.asp?text=21291#LOG4J-Basics-Logger">Logger</a> 
</dt><dt>3.2. <a href="http://www.csdn.net/editor/data.asp?text=21291#LOG4J-Basics-Appender">Appender</a> 
</dt><dd>
<dl><dt>3.2.1. <a href="http://www.csdn.net/editor/data.asp?text=21291#LOG4J-Basics-Appender-ConsoleAppender">使用ConsoleAppender</a> 
</dt><dt>3.2.2. <a href="http://www.csdn.net/editor/data.asp?text=21291#LOG4J-Basics-Appender-FileAppender">使用FileAppender</a> 
</dt><dt>3.2.3. <a href="http://www.csdn.net/editor/data.asp?text=21291#LOG4J-Basics-Appender-WriterAppender">使用WriterAppender</a></dt></dl>
</dd><dt>3.3. <a href="http://www.csdn.net/editor/data.asp?text=21291#LOG4J-Basics-Layout">Layout</a> 
</dt><dt>3.4. <a href="http://www.csdn.net/editor/data.asp?text=21291#LOG4J-Basics-Basics-Example">基本示例</a> 
</dt><dd>
<dl><dt>3.4.1. <a href="http://www.csdn.net/editor/data.asp?text=21291#LOG4J-Basics-Basics-Example-SimpAndFile">SimpleLayout和FileAppender</a> 
</dt><dt>3.4.2. <a href="http://www.csdn.net/editor/data.asp?text=21291#LOG4J-Basics-Basics-Example-HTMLandFile">HTMLLayout和WriterAppender</a> 
</dt><dt>3.4.3. <a href="http://www.csdn.net/editor/data.asp?text=21291#LOG4J-Basics-Basics-Example-consandpatt">PatternLayout和ConsoleAppender</a></dt></dl></dd></dl>
</dd><dt>4. <a href="http://www.csdn.net/editor/data.asp?text=21291#LOG4J-External-Config-File">使用外部配置文件</a> 
</dt><dt>5. <a href="http://supportweb.cs.bham.ac.uk/documentation/tutorials/docsystem/build/tutorials/log4j/log4j.html#LOG4J-References">参考资料 (以及一些有参考价值的链接)</a></dt></dl></div>
<div class="sect1" xmlns="http://www.w3.org/1999/xhtml">
<div class="titlepage" xmlns="http://www.w3.org/1999/xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<h2 class="title" style="clear: both;" xmlns="http://www.w3.org/1999/xhtml"><a id="LOG4J-Introduction" xmlns="http://www.w3.org/1999/xhtml">1.简介</a></h2></div></div>
<p xmlns="http://www.w3.org/1999/xhtml"><a id="LOG4J-Introduction" xmlns="http://www.w3.org/1999/xhtml">程
序开发环境中的日志记录是由嵌入在程序中以输出一些对开发人员有用信息的语句所组成。例如，跟踪语句（trace），结构转储和常见的
System.out.println或printf调试语句。log4j提供分级方法在程序中嵌入日志记录语句。日志信息具有多种输出格式和多个输出级
别。 </a></p>
<p xmlns="http://www.w3.org/1999/xhtml"><a id="LOG4J-Introduction" xmlns="http://www.w3.org/1999/xhtml">使
用一个专门的日志记录包，可以减轻对成千上万的System.out.println语句的维护成本，因为日志记录可以通过配置脚本在运行时得以控制。
log4j维护嵌入在程序代码中的日志记录语句。通过规范日志记录的处理过程，一些人认为应该鼓励更多的使用日志记录并且获得更高程度的效率。 </a></p></div>
<div class="sect1" xmlns="http://www.w3.org/1999/xhtml">
<div class="titlepage" xmlns="http://www.w3.org/1999/xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<h2 class="title" style="clear: both;" xmlns="http://www.w3.org/1999/xhtml"><a id="LOG4J-Installation" xmlns="http://www.w3.org/1999/xhtml">2.安装</a></h2></div></div>
<p xmlns="http://www.w3.org/1999/xhtml"><a id="LOG4J-Installation" xmlns="http://www.w3.org/1999/xhtml">为了使用我们即将要安装的日志记录工具，还必须要设置操作环境，只有这样，工具才能知道从哪里找到它所需要的信息，并且操作系统知道从哪里找到这个工具。那么，怎样做呢？实际上，它要求更改操作环境。我有一些这方面的资格文档。 </a><a href="http://supportweb.cs.bham.ac.uk/documentation/tutorials/docsystem/build/tutorials/winenvars/winenvarshome.html" target="_top"><i>Configuring A Windows Working Environment</i></a> 和 <a href="http://supportweb.cs.bham.ac.uk/documentation/tutorials/docsystem/build/tutorials/unixenvars/unixenvarshome.html" target="_top"><i>Configuring A Unix Working Environment</i></a>. </p>
<div class="orderedlist" xmlns="http://www.w3.org/1999/xhtml">
<ol type="1"><li xmlns="http://www.w3.org/1999/xhtml">
<p xmlns="http://www.w3.org/1999/xhtml">从 <a href="http://jakarta.apache.org/log4j/docs/download.html" target="_top">http://jakarta.apache.org/log4j/docs/download.html</a>下载log4j发行版。 </p>
</li><li xmlns="http://www.w3.org/1999/xhtml">
<p xmlns="http://www.w3.org/1999/xhtml">解压存档文件到合适的目录中。</p>
</li><li xmlns="http://www.w3.org/1999/xhtml">
<p xmlns="http://www.w3.org/1999/xhtml">添加文件 dist/lib/log4j-1.2.6.jar 到 CLASSPATH 环境变量中。 </p></li></ol></div></div>
<div class="sect1" xmlns="http://www.w3.org/1999/xhtml">
<div class="titlepage" xmlns="http://www.w3.org/1999/xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<h2 class="title" style="clear: both;" xmlns="http://www.w3.org/1999/xhtml"><a id="LOG4J-Basics" xmlns="http://www.w3.org/1999/xhtml">3.log4j的基本概念 </a></h2></div></div>
<p xmlns="http://www.w3.org/1999/xhtml"><a id="LOG4J-Basics" xmlns="http://www.w3.org/1999/xhtml">使用log4j大概涉及3个主要概念:</a></p>
<div class="orderedlist" xmlns="http://www.w3.org/1999/xhtml">
<ol type="1"><li xmlns="http://www.w3.org/1999/xhtml">
<p xmlns="http://www.w3.org/1999/xhtml"><span class="strong"><a id="LOG4J-Basics" xmlns="http://www.w3.org/1999/xhtml">公共类 Logger</a></span></p>
<p xmlns="http://www.w3.org/1999/xhtml"><span class="strong"><a id="LOG4J-Basics" xmlns="http://www.w3.org/1999/xhtml">Logger</a></span><a id="LOG4J-Basics" xmlns="http://www.w3.org/1999/xhtml"> 负责处理日志记录的大部分操作。 </a></p>
</li><li xmlns="http://www.w3.org/1999/xhtml">
<p xmlns="http://www.w3.org/1999/xhtml"><span class="strong"><a id="LOG4J-Basics" xmlns="http://www.w3.org/1999/xhtml">公共接口 Appender</a></span></p>
<p xmlns="http://www.w3.org/1999/xhtml"><span class="emphasis"><a id="LOG4J-Basics" xmlns="http://www.w3.org/1999/xhtml"><em>Appender</em></a></span><a id="LOG4J-Basics" xmlns="http://www.w3.org/1999/xhtml"> 负责控制日志记录操作的输出。 </a></p>
</li><li xmlns="http://www.w3.org/1999/xhtml">
<p xmlns="http://www.w3.org/1999/xhtml"><span class="strong"><a id="LOG4J-Basics" xmlns="http://www.w3.org/1999/xhtml">公共抽象类Layout</a></span></p>
<p xmlns="http://www.w3.org/1999/xhtml"><span class="strong"><a id="LOG4J-Basics" xmlns="http://www.w3.org/1999/xhtml">Layout</a></span><a id="LOG4J-Basics" xmlns="http://www.w3.org/1999/xhtml"> 负责格式化<span class="strong">Appender</span>的输出。 </a></p></li></ol></div>
<div class="sect2" xmlns="http://www.w3.org/1999/xhtml">
<div class="titlepage" xmlns="http://www.w3.org/1999/xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<h3 class="title" xmlns="http://www.w3.org/1999/xhtml"><a id="LOG4J-Basics-Logger" xmlns="http://www.w3.org/1999/xhtml">3.1.Logger</a></h3></div></div>
<p xmlns="http://www.w3.org/1999/xhtml"><a id="LOG4J-Basics-Logger" xmlns="http://www.w3.org/1999/xhtml">日志记录器(Logger)是日志处理的核心组件。log4j具有5种正常级别(Level)。 日志记录器(Logger)的可用级别<span class="strong">Level</span> (不包括自定义级别 <span class="strong">Level</span>)， 以下内容就是摘自log4j API (</a><a href="http://jakarta.apache.org/log4j/docs/api/index.html" target="_top">http://jakarta.apache.org/log4j/docs/api/index.html</a>): </p>
<div class="itemizedlist" xmlns="http://www.w3.org/1999/xhtml">
<ul type="disc"><li xmlns="http://www.w3.org/1999/xhtml">
<p xmlns="http://www.w3.org/1999/xhtml"><span class="strong">static Level DEBUG</span> </p>
<p xmlns="http://www.w3.org/1999/xhtml">DEBUG Level指出细粒度信息事件对调试应用程序是非常有帮助的。</p>
</li><li xmlns="http://www.w3.org/1999/xhtml">
<p xmlns="http://www.w3.org/1999/xhtml"><span class="strong">static Level INFO</span> </p>
<p xmlns="http://www.w3.org/1999/xhtml">INFO level表明 消息在粗粒度级别上突出强调应用程序的运行过程。 </p>
</li><li xmlns="http://www.w3.org/1999/xhtml">
<p xmlns="http://www.w3.org/1999/xhtml"><span class="strong">static Level WARN</span></p>
<p xmlns="http://www.w3.org/1999/xhtml">WARN level表明会出现潜在错误的情形。</p>
</li><li xmlns="http://www.w3.org/1999/xhtml">
<p xmlns="http://www.w3.org/1999/xhtml"><span class="strong">static Level ERROR</span></p>
<p xmlns="http://www.w3.org/1999/xhtml">ERROR level指出虽然发生错误事件，但仍然不影响系统的继续运行。</p>
</li><li xmlns="http://www.w3.org/1999/xhtml">
<p xmlns="http://www.w3.org/1999/xhtml"><span class="strong">static Level FATAL</span></p>
<p xmlns="http://www.w3.org/1999/xhtml">FATAL level指出每个严重的错误事件将会导致应用程序的退出。</p></li></ul></div>
<p xmlns="http://www.w3.org/1999/xhtml">另外，还有两个可用的特别的日志记录级别: (以下描述来自log4j API <a href="http://jakarta.apache.org/log4j/docs/api/index.html" target="_top">http://jakarta.apache.org/log4j/docs/api/index.html</a>): </p>
<div class="itemizedlist" xmlns="http://www.w3.org/1999/xhtml">
<ul type="disc"><li xmlns="http://www.w3.org/1999/xhtml">
<p xmlns="http://www.w3.org/1999/xhtml"><span class="strong">static Level ALL</span></p>
<p xmlns="http://www.w3.org/1999/xhtml">ALL Level是最低等级的，用于打开所有日志记录。 </p>
</li><li xmlns="http://www.w3.org/1999/xhtml">
<p xmlns="http://www.w3.org/1999/xhtml"><span class="strong">static Level OFF</span></p>
<p xmlns="http://www.w3.org/1999/xhtml">OFF Level是最高等级的，用于关闭所有日志记录。 </p></li></ul></div>
<p xmlns="http://www.w3.org/1999/xhtml">日志记录器（Logger）的行为是分等级的。如下表所示：</p>
<div class="figure" xmlns="http://www.w3.org/1999/xhtml"><a id="id215962" xmlns="http://www.w3.org/1999/xhtml">
</a><p class="title" xmlns="http://www.w3.org/1999/xhtml"><a id="id215962" xmlns="http://www.w3.org/1999/xhtml"><b>图.日志输出等级</b></a></p>
<div class="mediaobject" xmlns="http://www.w3.org/1999/xhtml"><a id="id215962" xmlns="http://www.w3.org/1999/xhtml"><img alt="Logger Output Hierarchy" src="g:%5Cmydoc%5Cresearch%5CLog4J.files%5Cloggerlevels.png" border="0" hspace="0"></a></div></div>
<p xmlns="http://www.w3.org/1999/xhtml"><a id="id215962" xmlns="http://www.w3.org/1999/xhtml">日志记录器（Logger）将只输出那些级别高于或等于它的级别的信息。如果没有设置日志记录器（Logger）的级别，那么它将会继承最近的祖先的级别。因此，如果在包<span class="strong">com.foo.bar</span>中创建一个日志记录器（Logger）并且没有设置级别，那它将会继承在包<span class="strong">com.foo</span>中创建的日志记录器（Logger）的级别。如果在<span class="strong">com.foo</span>中没有创建日志记录器（Logger）的话,那么在<span class="strong">com.foo.bar</span>中创建的日志记录器（Logger）将继承<span class="strong">root</span> 日志记录器（Logger）的级别，root日志记录器（Logger）经常被实例化而可用，它的级别为<span class="strong">DEBUG</span>。 </a></p>
<p xmlns="http://www.w3.org/1999/xhtml"><a id="id215962" xmlns="http://www.w3.org/1999/xhtml">有很多方法可以创建一个日志记录器（Logger），下面方法可以取回root日志记录器:</a></p>
<table bgcolor="#e0e0e0" border="0" width="90%">
<tbody>
<tr>
<td><pre class="programlisting">Logger logger = Logger.getRootLogger();</pre></td></tr></tbody></table>
<p xmlns="http://www.w3.org/1999/xhtml"><a id="id215962" xmlns="http://www.w3.org/1999/xhtml">还可以这样创建一个新的日志记录器:</a></p>
<table bgcolor="#e0e0e0" border="0" width="90%">
<tbody>
<tr>
<td><pre class="programlisting">Logger logger = Logger.getLogger("MyLogger");</pre></td></tr></tbody></table>
<p xmlns="http://www.w3.org/1999/xhtml"><a id="id215962" xmlns="http://www.w3.org/1999/xhtml">比较常用的用法，就是根据类名实例化一个静态的全局日志记录器:</a></p>
<table bgcolor="#e0e0e0" border="0" width="90%">
<tbody>
<tr>
<td><pre class="programlisting">static Logger logger = Logger.getLogger(test.class);</pre></td></tr></tbody></table>
<p xmlns="http://www.w3.org/1999/xhtml"><a id="id215962" xmlns="http://www.w3.org/1999/xhtml">所有这些创建的叫"logger"的日志记录器都可以用下面方法设置级别:</a></p>
<table bgcolor="#e0e0e0" border="0" width="90%">
<tbody>
<tr>
<td><pre class="programlisting">logger.setLevel((Level)Level.WARN);</pre></td></tr></tbody></table>
<p xmlns="http://www.w3.org/1999/xhtml"><a id="id215962" xmlns="http://www.w3.org/1999/xhtml">可以使用7个级别中的任何一个; Level.DEBUG, Level.INFO, Level.WARN, Level.ERROR, Level.FATAL, Level.ALL and Level.OFF. </a></p></div>
<div class="sect2" xmlns="http://www.w3.org/1999/xhtml">
<div class="titlepage" xmlns="http://www.w3.org/1999/xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<h3 class="title" xmlns="http://www.w3.org/1999/xhtml"><a id="LOG4J-Basics-Appender" xmlns="http://www.w3.org/1999/xhtml">3.2.Appender</a></h3></div></div>
<p xmlns="http://www.w3.org/1999/xhtml"><span class="strong"><a id="LOG4J-Basics-Appender" xmlns="http://www.w3.org/1999/xhtml">Appender</a></span><a id="LOG4J-Basics-Appender" xmlns="http://www.w3.org/1999/xhtml"> 控制日志怎样输出。下面列出一些可用的Appender(log4j API中所描述的 </a><a href="http://jakarta.apache.org/log4j/docs/api/index.html" target="_top">http://jakarta.apache.org/log4j/docs/api/index.html</a>): </p>
<div class="orderedlist" xmlns="http://www.w3.org/1999/xhtml">
<ol type="1"><li xmlns="http://www.w3.org/1999/xhtml">
<p xmlns="http://www.w3.org/1999/xhtml"><span class="strong">ConsoleAppender:</span>使用用户指定的布局(layout) 输出日志事件到System.out或者 System.err。默认的目标是System.out。 </p>
</li><li xmlns="http://www.w3.org/1999/xhtml">
<p xmlns="http://www.w3.org/1999/xhtml"><span class="strong">DailyRollingFileAppender</span> 扩展FileAppender，因此多个日志文件可以以一个用户选定的频率进行循环日志记录。 </p>
</li><li xmlns="http://www.w3.org/1999/xhtml">
<p xmlns="http://www.w3.org/1999/xhtml"><span class="strong">FileAppender</span> 把日志事件写入一个文件 </p>
</li><li xmlns="http://www.w3.org/1999/xhtml">
<p xmlns="http://www.w3.org/1999/xhtml"><span class="strong">RollingFileAppender</span> 扩展FileAppender备份容量达到一定大小的日志文件。</p>
</li><li xmlns="http://www.w3.org/1999/xhtml">
<p xmlns="http://www.w3.org/1999/xhtml"><span class="strong">WriterAppender</span>根据用户的选择把日志事件写入到Writer或者OutputStream。 </p>
</li><li xmlns="http://www.w3.org/1999/xhtml">
<p xmlns="http://www.w3.org/1999/xhtml"><span class="strong">SMTPAppender</span> 当特定的日志事件发生时，一般是指发生错误或者重大错误时，发送一封邮件。 </p>
</li><li xmlns="http://www.w3.org/1999/xhtml">
<p xmlns="http://www.w3.org/1999/xhtml"><span class="strong">SocketAppender</span> 给远程日志服务器（通常是网络套接字节点）发送日志事件（LoggingEvent）对象。</p>
</li><li xmlns="http://www.w3.org/1999/xhtml">
<p xmlns="http://www.w3.org/1999/xhtml"><span class="strong">SocketHubAppender</span> 给远程日志服务器群组（通常是网络套接字节点）发送日志事件（LoggingEvent）对象。</p>
</li><li xmlns="http://www.w3.org/1999/xhtml">
<p xmlns="http://www.w3.org/1999/xhtml"><span class="strong">SyslogAppender</span>给远程异步日志记录的后台精灵程序(daemon)发送消息。 </p>
</li><li xmlns="http://www.w3.org/1999/xhtml">
<p xmlns="http://www.w3.org/1999/xhtml"><span class="strong">TelnetAppender</span> 一个专用于向只读网络套接字发送消息的log4j appender。 </p></li></ol></div>
<p xmlns="http://www.w3.org/1999/xhtml">还可以实现 <span class="emphasis"><em>Appender</em></span> 接口，创建以自己的方式进行日志输出的Appender。 </p>
<div class="sect3" xmlns="http://www.w3.org/1999/xhtml">
<div class="titlepage" xmlns="http://www.w3.org/1999/xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<h4 class="title" xmlns="http://www.w3.org/1999/xhtml"><a id="LOG4J-Basics-Appender-ConsoleAppender" xmlns="http://www.w3.org/1999/xhtml">3.2.1.使用ConsoleAppender</a></h4></div></div>
<p xmlns="http://www.w3.org/1999/xhtml"><a id="LOG4J-Basics-Appender-ConsoleAppender" xmlns="http://www.w3.org/1999/xhtml">ConsoleAppender可以用这种方式创建：</a></p>
<table bgcolor="#e0e0e0" border="0" width="90%">
<tbody>
<tr>
<td><pre class="programlisting">ConsoleAppender appender = new ConsoleAppender(new PatternLayout());</pre></td></tr></tbody></table>
<p xmlns="http://www.w3.org/1999/xhtml"><a id="LOG4J-Basics-Appender-ConsoleAppender" xmlns="http://www.w3.org/1999/xhtml">创建了一个控制台appender，具有一个默认的PatternLayout。它使用了默认的<span class="strong">System.out</span> 输出。 </a></p></div>
<div class="sect3" xmlns="http://www.w3.org/1999/xhtml">
<div class="titlepage" xmlns="http://www.w3.org/1999/xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<h4 class="title" xmlns="http://www.w3.org/1999/xhtml"><a id="LOG4J-Basics-Appender-FileAppender" xmlns="http://www.w3.org/1999/xhtml">3.2.2.使用FileAppender</a></h4></div></div>
<p xmlns="http://www.w3.org/1999/xhtml"><a id="LOG4J-Basics-Appender-FileAppender" xmlns="http://www.w3.org/1999/xhtml">FileAppender可以用这种方式创建:</a></p>
<table bgcolor="#e0e0e0" border="0" width="90%">
<tbody>
<tr>
<td><pre class="programlisting">          FileAppender appender = null;<br>          try {<br>             appender = new FileAppender(new PatternLayout(),"filename");<br>          } catch(Exception e) {}<br>        </pre></td></tr></tbody></table>
<p xmlns="http://www.w3.org/1999/xhtml"><a id="LOG4J-Basics-Appender-FileAppender" xmlns="http://www.w3.org/1999/xhtml">上面用到的构造函数:</a></p>
<table bgcolor="#e0e0e0" border="0" width="90%">
<tbody>
<tr>
<td><pre class="programlisting">FileAppender(Layout layout, String filename) <br>          实例化一个FileAppender并且打开变量"filename"指定的文件。<br>        </pre></td></tr></tbody></table>
<p xmlns="http://www.w3.org/1999/xhtml"><a id="LOG4J-Basics-Appender-FileAppender" xmlns="http://www.w3.org/1999/xhtml">另一个有用的构造函数是：</a></p>
<table bgcolor="#e0e0e0" border="0" width="90%">
<tbody>
<tr>
<td><pre class="programlisting">FileAppender(Layout layout, String filename, boolean append) <br>          实例化一个FileAppender并且打开变量"filename"指定的文件。<br>        </pre></td></tr></tbody></table>
<p xmlns="http://www.w3.org/1999/xhtml"><a id="LOG4J-Basics-Appender-FileAppender" xmlns="http://www.w3.org/1999/xhtml">这个构造函数还可以选择是否对指定的文件进行追加的方式输出。如果没有指定值，那么默认的方式就是追加。 </a></p></div>
<div class="sect3" xmlns="http://www.w3.org/1999/xhtml">
<div class="titlepage" xmlns="http://www.w3.org/1999/xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<h4 class="title" xmlns="http://www.w3.org/1999/xhtml"><a id="LOG4J-Basics-Appender-WriterAppender" xmlns="http://www.w3.org/1999/xhtml">3.2.3.使用WriterAppender</a></h4></div></div>
<p xmlns="http://www.w3.org/1999/xhtml"><a id="LOG4J-Basics-Appender-WriterAppender" xmlns="http://www.w3.org/1999/xhtml">WriterAppender可以用这种方式创建:</a></p>
<table bgcolor="#e0e0e0" border="0" width="90%">
<tbody>
<tr>
<td><pre class="programlisting">          WriterAppender appender = null;<br>          try {<br>            appender = new WriterAppender(new PatternLayout(),new FileOutputStream("filename"));<br>          } catch(Exception e) {}<br>        </pre></td></tr></tbody></table>
<p xmlns="http://www.w3.org/1999/xhtml"><a id="LOG4J-Basics-Appender-WriterAppender" xmlns="http://www.w3.org/1999/xhtml">这个WriterAppender使用的构造函数带有PatternLayout和OutputStream参数，在这种情况下， FileOutputStream用于向一个文件输出。当然，它还具有其他可用的构造函数。 </a></p></div></div>
<div class="sect2" xmlns="http://www.w3.org/1999/xhtml">
<div class="titlepage" xmlns="http://www.w3.org/1999/xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<h3 class="title" xmlns="http://www.w3.org/1999/xhtml"><a id="LOG4J-Basics-Layout" xmlns="http://www.w3.org/1999/xhtml">3.3.Layout</a></h3></div></div>
<p xmlns="http://www.w3.org/1999/xhtml"><a id="LOG4J-Basics-Layout" xmlns="http://www.w3.org/1999/xhtml">Appender必须使用一个与之相关联的 <span class="strong">Layout</span>，这样它才能知道怎样格式化它的输出。当前，log4j具有三种类型的Layout: </a></p>
<div class="orderedlist" xmlns="http://www.w3.org/1999/xhtml">
<ol type="1"><li xmlns="http://www.w3.org/1999/xhtml">
<p xmlns="http://www.w3.org/1999/xhtml"><span class="strong"><a id="LOG4J-Basics-Layout" xmlns="http://www.w3.org/1999/xhtml">HTMLLayout</a></span><a id="LOG4J-Basics-Layout" xmlns="http://www.w3.org/1999/xhtml"> 格式化日志输出为HTML表格。 </a></p>
</li><li xmlns="http://www.w3.org/1999/xhtml">
<p xmlns="http://www.w3.org/1999/xhtml"><span class="strong"><a id="LOG4J-Basics-Layout" xmlns="http://www.w3.org/1999/xhtml">PatternLayout</a></span><a id="LOG4J-Basics-Layout" xmlns="http://www.w3.org/1999/xhtml"> 根据指定的 <span class="emphasis"><em>转换模式</em></span>格式化日志输出，或者如果没有指定任何转换模式，就使用默认的转换模式。 </a></p>
</li><li xmlns="http://www.w3.org/1999/xhtml">
<p xmlns="http://www.w3.org/1999/xhtml"><span class="strong"><a id="LOG4J-Basics-Layout" xmlns="http://www.w3.org/1999/xhtml">SimpleLayout</a></span><a id="LOG4J-Basics-Layout" xmlns="http://www.w3.org/1999/xhtml"> 以一种非常简单的方式格式化日志输出，它打印级别 <span class="strong">Level</span>，然后跟着一个破折号“-“ ，最后才是日志消息。 </a></p></li></ol></div></div>
<div class="sect2" xmlns="http://www.w3.org/1999/xhtml">
<div class="titlepage" xmlns="http://www.w3.org/1999/xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<h3 class="title" xmlns="http://www.w3.org/1999/xhtml"><a id="LOG4J-Basics-Basics-Example" xmlns="http://www.w3.org/1999/xhtml">3.4.基本示例</a></h3></div></div>
<div class="sect3" xmlns="http://www.w3.org/1999/xhtml">
<div class="titlepage" xmlns="http://www.w3.org/1999/xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<h4 class="title" xmlns="http://www.w3.org/1999/xhtml"><a id="LOG4J-Basics-Basics-Example-SimpAndFile" xmlns="http://www.w3.org/1999/xhtml">3.4.1.SimpleLayout和 FileAppender</a></h4></div></div>
<p xmlns="http://www.w3.org/1999/xhtml"><a id="LOG4J-Basics-Basics-Example-SimpAndFile" xmlns="http://www.w3.org/1999/xhtml">这里是一个非常简单的例子，程序实现了SimpleLayout和FileAppender:</a></p>
<table bgcolor="#e0e0e0" border="0" width="90%">
<tbody>
<tr>
<td><pre class="programlisting">import org.apache.log4j.Level;<br>import org.apache.log4j.Logger;<br>import org.apache.log4j.SimpleLayout;<br>import org.apache.log4j.FileAppender;<br>public class simpandfile {<br>   static Logger logger = Logger.getLogger(simpandfile.class);<br>   public static void main(String args[]) {<br>      SimpleLayout layout = new SimpleLayout();<br>      FileAppender appender = null;<br>      try {<br>         appender = new FileAppender(layout,"output1.txt",false);<br>      } catch(Exception e) {}<br>      logger.addAppender(appender);<br>      logger.setLevel((Level) Level.DEBUG);<br>      logger.debug("Here is some DEBUG");<br>      logger.info("Here is some INFO");<br>      logger.warn("Here is some WARN");<br>      logger.error("Here is some ERROR");<br>      logger.fatal("Here is some FATAL");<br>   }<br>}<br>        </pre></td></tr></tbody></table>
<p xmlns="http://www.w3.org/1999/xhtml"><a id="LOG4J-Basics-Basics-Example-SimpAndFile" xmlns="http://www.w3.org/1999/xhtml">你可以下载: </a><a href="http://supportweb.cs.bham.ac.uk/documentation/tutorials/docsystem/build/tutorials/log4j/files/simpandfile.java" target="_top">simpandfile.java</a>。 还可以查看它的输出： <a href="http://supportweb.cs.bham.ac.uk/documentation/tutorials/docsystem/build/tutorials/log4j/files/output1.txt" target="_top">output1.txt</a>. </p></div>
<div class="sect3" xmlns="http://www.w3.org/1999/xhtml">
<div class="titlepage" xmlns="http://www.w3.org/1999/xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<h4 class="title" xmlns="http://www.w3.org/1999/xhtml"><a id="LOG4J-Basics-Basics-Example-HTMLandFile" xmlns="http://www.w3.org/1999/xhtml">3.4.2.HTMLLayout和 WriterAppender</a></h4></div></div>
<p xmlns="http://www.w3.org/1999/xhtml"><a id="LOG4J-Basics-Basics-Example-HTMLandFile" xmlns="http://www.w3.org/1999/xhtml">这里是一个非常简单的例子，程序实现了 HTMLLayout和WriterAppender:</a></p>
<table bgcolor="#e0e0e0" border="0" width="90%">
<tbody>
<tr>
<td><pre class="programlisting">import java.io.*;<br>import org.apache.log4j.Level;<br>import org.apache.log4j.Logger;<br>import org.apache.log4j.HTMLLayout;<br>import org.apache.log4j.WriterAppender;<br>public class htmlandwrite {<br>   static Logger logger = Logger.getLogger(htmlandwrite.class);<br>   public static void main(String args[]) {<br>      HTMLLayout layout = new HTMLLayout();<br>      WriterAppender appender = null;<br>      try {<br>         FileOutputStream output = new FileOutputStream("output2.html");<br>         appender = new WriterAppender(layout,output);<br>      } catch(Exception e) {}<br>      logger.addAppender(appender);<br>      logger.setLevel((Level) Level.DEBUG);<br>      logger.debug("Here is some DEBUG");<br>      logger.info("Here is some INFO");<br>      logger.warn("Here is some WARN");<br>      logger.error("Here is some ERROR");<br>      logger.fatal("Here is some FATAL");<br>   }<br>}<br>        </pre></td></tr></tbody></table>
<p xmlns="http://www.w3.org/1999/xhtml"><a id="LOG4J-Basics-Basics-Example-HTMLandFile" xmlns="http://www.w3.org/1999/xhtml">你可以下载: </a><a href="http://supportweb.cs.bham.ac.uk/documentation/tutorials/docsystem/build/tutorials/log4j/files/htmlandwrite.java" target="_top">simpandfile.java</a>. 还可以查看它的输出：<a href="http://supportweb.cs.bham.ac.uk/documentation/tutorials/docsystem/build/tutorials/log4j/files/output2.html" target="_top">output1.txt</a>. </p></div>
<div class="sect3" xmlns="http://www.w3.org/1999/xhtml">
<div class="titlepage" xmlns="http://www.w3.org/1999/xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<h4 class="title" xmlns="http://www.w3.org/1999/xhtml"><a id="LOG4J-Basics-Basics-Example-consandpatt" xmlns="http://www.w3.org/1999/xhtml">3.4.3.PatternLayout和 ConsoleAppender</a></h4></div></div>
<p xmlns="http://www.w3.org/1999/xhtml"><a id="LOG4J-Basics-Basics-Example-consandpatt" xmlns="http://www.w3.org/1999/xhtml">这里是一个非常简单的例子，程序实现了PatternLayout和ConsoleAppender:</a></p>
<table bgcolor="#e0e0e0" border="0" width="90%">
<tbody>
<tr>
<td><pre class="programlisting">import org.apache.log4j.Level;<br>import org.apache.log4j.Logger;<br>import org.apache.log4j.PatternLayout;<br>import org.apache.log4j.ConsoleAppender;<br>public class consandpatt {<br>   static Logger logger = Logger.getLogger(consandpatt.class);<br>   public static void main(String args[]) {<br>      // Note, %n is newline<br>      String pattern =  "Milliseconds since program start: %r %n";<br>             pattern += "Classname of caller: %C %n";<br>             pattern += "Date in ISO8601 format: %d{ISO8601} %n";<br>             pattern += "Location of log event: %l %n";<br>             pattern += "Message: %m %n %n"; <br>      <br>      PatternLayout layout = new PatternLayout(pattern);<br>      ConsoleAppender appender = new ConsoleAppender(layout);<br>      logger.addAppender(appender);<br>      logger.setLevel((Level) Level.DEBUG);<br>      logger.debug("Here is some DEBUG");<br>      logger.info("Here is some INFO");<br>      logger.warn("Here is some WARN");<br>      logger.error("Here is some ERROR");<br>      logger.fatal("Here is some FATAL");<br>   }<br>}<br>        </pre></td></tr></tbody></table>
<p xmlns="http://www.w3.org/1999/xhtml"><a id="LOG4J-Basics-Basics-Example-consandpatt" xmlns="http://www.w3.org/1999/xhtml">你可以下载:</a><a href="http://supportweb.cs.bham.ac.uk/documentation/tutorials/docsystem/build/tutorials/log4j/files/consandpatt.java" target="_top">simpandfile.java</a>. 还可以查看它的输出： <a href="http://supportweb.cs.bham.ac.uk/documentation/tutorials/docsystem/build/tutorials/log4j/files/output2.txt" target="_top">output2.txt</a>. </p></div></div></div>
<div class="sect1" xmlns="http://www.w3.org/1999/xhtml">
<div class="titlepage" xmlns="http://www.w3.org/1999/xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<h2 class="title" style="clear: both;" xmlns="http://www.w3.org/1999/xhtml"><a id="LOG4J-External-Config-File" xmlns="http://www.w3.org/1999/xhtml">4.使用外部配置文件</a></h2></div></div>
<p xmlns="http://www.w3.org/1999/xhtml"><a id="LOG4J-External-Config-File" xmlns="http://www.w3.org/1999/xhtml">Log4j经常与外部日志文件联合使用，这样很多可选项不必硬编码在软件中。使用外部配置文件的优点就是修改可选项不需要重新编译程序。唯一的缺点就是，由于用到<span class="emphasis"><em>io</em></span> 指令，速度稍微有些减慢。 </a></p>
<p xmlns="http://www.w3.org/1999/xhtml"><a id="LOG4J-External-Config-File" xmlns="http://www.w3.org/1999/xhtml">有两个方法可以用来指定外部配置文件：文本文件或者XML文件。既然现在所有事情都写成XML文件，那么该教程就重点讲解XML文件方法，但是也包含相关文本文件的例子。首先，看看下面的XML配置文件示例：</a></p>
<table bgcolor="#e0e0e0" border="0" width="90%">
<tbody>
<tr>
<td><pre class="programlisting">&lt;?xml version="1.0" encoding="UTF-8" ?&gt;<br>&lt;!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"&gt;<br>&lt;log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"&gt;<br>        <br>  &lt;appender name="ConsoleAppender" class="org.apache.log4j.ConsoleAppender"&gt;<br>    &lt;layout class="org.apache.log4j.SimpleLayout"/&gt;<br>  &lt;/appender&gt;<br>  &lt;root&gt;<br>    &lt;priority value ="debug" /&gt;<br>    &lt;appender-ref ref="ConsoleAppender"/&gt;<br>  &lt;/root&gt;<br>&lt;/log4j:configuration&gt; <br>    </pre></td></tr></tbody></table>
<p xmlns="http://www.w3.org/1999/xhtml"><a id="LOG4J-External-Config-File" xmlns="http://www.w3.org/1999/xhtml">文件以标准的XML声明作为开始，后面跟着指出DTD（文档类型定义）的DOCTYPE声明，它定义了XML文件的结构，例如，什么元素可以嵌入在其他元素中等等。上面文件在log4j发行版的src/java/org/apache/log4j/xml目录中。 接着看看封装所有元素的 <span class="strong">log4j:configuration</span> 元素，它在DOCTYPE声明中被指定为根元素。嵌入在根元素中有两个结构： </a></p>
<table bgcolor="#e0e0e0" border="0" width="90%">
<tbody>
<tr>
<td><pre class="programlisting">  &lt;appender name="ConsoleAppender" class="org.apache.log4j.ConsoleAppender"&gt;<br>    &lt;layout class="org.apache.log4j.SimpleLayout"/&gt;<br>  &lt;/appender&gt;      <br>    </pre></td></tr></tbody></table>
<p xmlns="http://www.w3.org/1999/xhtml"><a id="LOG4J-External-Config-File" xmlns="http://www.w3.org/1999/xhtml">这里创建一个名叫"ConsoleAppender"的 <span class="emphasis"><em>Appender</em></span>，注意，你可以选择任何名字，该示例之所以选择"ConsoleAppender"，完全是为了示例的设计。接着这个appender类以全名形式给出，经常用规范（fully qualified）类名。 <span class="emphasis"><em>Appender</em></span>必须具有一个指定的 <span class="emphasis"><em>name</em></span>和<span class="emphasis"><em>class</em></span>。嵌入在 <span class="emphasis"><em>Appender</em></span>之内的是 <span class="emphasis"><em>layout</em></span>元素，这里它被指定为SimpleLayout。 <span class="emphasis"><em>Layout</em></span> 必须具有一个 <span class="emphasis"><em>class</em></span>属性。 </a></p>
<table bgcolor="#e0e0e0" border="0" width="90%">
<tbody>
<tr>
<td><pre class="programlisting">  &lt;root&gt;<br>    &lt;priority value ="debug" /&gt;<br>    &lt;appender-ref ref="ConsoleAppender"/&gt;<br>  &lt;/root&gt;      <br>    </pre></td></tr></tbody></table>
<p xmlns="http://www.w3.org/1999/xhtml"><a id="LOG4J-External-Config-File" xmlns="http://www.w3.org/1999/xhtml">root元素必须存在且不能被子类化。示例中的优先级被设置为"debug"，设置appender饱含一个<span class="emphasis"><em>appender-ref</em></span>元素。还有更多的属性或元素可以指定。查看log4j发行版中的src/java/org/apache/log4j/xml/log4j.dtd以了解关于XML配置文件结构的更多信息。可以用下面这种方法把配置信息文件读入到Java程序中: </a></p>
<table bgcolor="#e0e0e0" border="0" width="90%">
<tbody>
<tr>
<td><pre class="programlisting">DOMConfigurator.configure("configurationfile.xml");<br>    </pre></td></tr></tbody></table>
<p xmlns="http://www.w3.org/1999/xhtml"><span class="emphasis"><a id="LOG4J-External-Config-File" xmlns="http://www.w3.org/1999/xhtml"><em>DOMConfigurator</em></a></span><a id="LOG4J-External-Config-File" xmlns="http://www.w3.org/1999/xhtml"> 用一棵DOM树来初始化log4j环境。这里是示例中的XML配置文件：</a><a href="http://supportweb.cs.bham.ac.uk/documentation/tutorials/docsystem/build/tutorials/log4j/files/plainlog4jconfig.xml" target="_top">plainlog4jconfig.xml</a>。这里是执行该配置文件的程序: <a href="http://supportweb.cs.bham.ac.uk/documentation/tutorials/docsystem/build/tutorials/log4j/files/externalxmltest.java" target="_top">files/externalxmltest.java</a>: </p>
<table bgcolor="#e0e0e0" border="0" width="90%">
<tbody>
<tr>
<td><pre class="programlisting">import org.apache.log4j.Logger;<br>import org.apache.log4j.xml.DOMConfigurator;<br>public class externalxmltest {<br>   static Logger logger = Logger.getLogger(filetest.class);<br>   public static void main(String args[]) {<br>      DOMConfigurator.configure("xmllog4jconfig.xml");<br>      logger.debug("Here is some DEBUG");<br>      logger.info("Here is some INFO");<br>      logger.warn("Here is some WARN");<br>      logger.error("Here is some ERROR");<br>      logger.fatal("Here is some FATAL");<br>   }<br>}<br>    </pre></td></tr></tbody></table>
<p xmlns="http://www.w3.org/1999/xhtml">这里是一个实现带有<span class="emphasis"><em>PatternLayout</em></span>的<span class="emphasis"><em>FileAppender</em></span>的日志记录器Logger的XML配置文件: </p>
<table bgcolor="#e0e0e0" border="0" width="90%">
<tbody>
<tr>
<td><pre class="programlisting">&lt;?xml version="1.0" encoding="UTF-8" ?&gt;<br>&lt;!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"&gt;<br>&lt;log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"&gt;<br>        <br>  &lt;appender name="appender" class="org.apache.log4j.FileAppender"&gt;<br>    &lt;param name="File" value="Indentify-Log.txt"/&gt;<br>    &lt;param name="Append" value="false"/&gt;<br>    &lt;layout class="org.apache.log4j.PatternLayout"&gt;<br>      &lt;param name="ConversionPattern" value="%d [%t] %p - %m%n"/&gt;<br>    &lt;/layout&gt;<br>  &lt;/appender&gt;<br>  &lt;root&gt;<br>    &lt;priority value ="debug"/&gt;<br>    &lt;appender-ref ref="appender"/&gt;<br>  &lt;/root&gt;<br>&lt;/log4j:configuration&gt;<br>    </pre></td></tr></tbody></table>
<p xmlns="http://www.w3.org/1999/xhtml">你可以从这里下载示例: <a href="http://supportweb.cs.bham.ac.uk/documentation/tutorials/docsystem/build/tutorials/log4j/files/xmllog4jconfig2.xml" target="_top">xmllog4jconfig2.xml</a>。 想要得到更多的使用XML文件配置log4j环境的例子，请查看log4j发行版的目录src/java/org/apache/log4j/xml/examples/ 。 </p>
<p xmlns="http://www.w3.org/1999/xhtml">这就是上面讨论的文本文件形式的配置文件:</p>
<table bgcolor="#e0e0e0" border="0" width="90%">
<tbody>
<tr>
<td><pre class="programlisting"># initialise root logger with level DEBUG and call it BLAH<br>log4j.rootLogger=DEBUG, BLAH<br># add a ConsoleAppender to the logger BLAH<br>log4j.appender.BLAH=org.apache.log4j.ConsoleAppender<br># set set that layout to be SimpleLayout<br>log4j.appender.BLAH.layout=org.apache.log4j.SimpleLayout<br>    </pre></td></tr></tbody></table>
<p xmlns="http://www.w3.org/1999/xhtml">从这里可以下载: <a href="http://supportweb.cs.bham.ac.uk/documentation/tutorials/docsystem/build/tutorials/log4j/files/plainlog4jconfig.txt" target="_top">plainlog4jconfig.txt</a>。这就是执行该配置文件的程序: </p>
<table bgcolor="#e0e0e0" border="0" width="90%">
<tbody>
<tr>
<td><pre class="programlisting">import org.apache.log4j.Logger;<br>import org.apache.log4j.PropertyConfigurator;<br>public class externalplaintest {<br>   static Logger logger = Logger.getLogger(externalplaintest.class);<br>   public static void main(String args[]) {<br>      PropertyConfigurator.configure("plainlog4jconfig.xml");<br>      logger.debug("Here is some DEBUG");<br>      logger.info("Here is some INFO");<br>      logger.warn("Here is some WARN");<br>      logger.error("Here is some ERROR");<br>      logger.fatal("Here is some FATAL");<br>   }<br>}<br>    </pre></td></tr></tbody></table>
<p xmlns="http://www.w3.org/1999/xhtml">你可以下载使用该配置文件的示例： <a href="http://supportweb.cs.bham.ac.uk/documentation/tutorials/docsystem/build/tutorials/log4j/files/externalplaintest.java">externalplaintest.java</a>。想要获得更多的使用文本文件配置log4j环境的例子，请查看log4j发行版中的目录examples。 </p>
<p xmlns="http://www.w3.org/1999/xhtml">使用外部配置文件的例子就简单的讨论到这里，现在应该可以肯定你已经有能力独立学习更多的log4j发行版和测试版中提供的例子。</p></div>
<div class="sect1" xmlns="http://www.w3.org/1999/xhtml">
<div class="titlepage" xmlns="http://www.w3.org/1999/xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<h2 class="title" style="clear: both;" xmlns="http://www.w3.org/1999/xhtml"><a id="LOG4J-References" xmlns="http://www.w3.org/1999/xhtml">5.参考资料 (以及一些有参考价值的链接)</a></h2></div></div>
<div class="itemizedlist" xmlns="http://www.w3.org/1999/xhtml">
<ul type="disc"><li xmlns="http://www.w3.org/1999/xhtml">
<p xmlns="http://www.w3.org/1999/xhtml"><a href="http://jakarta.apache.org/log4j/docs/manual.html" target="_top">http://jakarta.apache.org/log4j/docs/manual.html</a></p>
<p xmlns="http://www.w3.org/1999/xhtml">log4j的简明介绍 - Ceki G- 2002年3月</p>
</li><li xmlns="http://www.w3.org/1999/xhtml">
<p xmlns="http://www.w3.org/1999/xhtml"><a href="http://www.vipan.com/htdocs/log4jhelp.html" target="_top">http://www.vipan.com/htdocs/log4jhelp.html</a></p>
<p xmlns="http://www.w3.org/1999/xhtml">不要用System.out.println！用Log4j - Vipan Singla </p>
</li><li xmlns="http://www.w3.org/1999/xhtml">
<p xmlns="http://www.w3.org/1999/xhtml"><a href="http://www.opensymphony.com/guidelines/logging.jsp" target="_top">http://www.opensymphony.com/guidelines/logging.jsp</a></p>
<p xmlns="http://www.w3.org/1999/xhtml">LOG4J / OpenSymphony日志记录入门</p>
</li><li xmlns="http://www.w3.org/1999/xhtml">
<p xmlns="http://www.w3.org/1999/xhtml"><a href="http://builder.com.com/article.jhtml?id=u00820020124kev01.htm" target="_top">http://builder.com.com/article.jhtml?id=u00820020124kev01.htm</a></p>
<p xmlns="http://www.w3.org/1999/xhtml">给你的Java应用程序添加日志记录 - Kevin Brown</p></li></ul></div></div></span></font><img src ="http://www.blogjava.net/Pudgy/aggbug/10449.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Pudgy/" target="_blank">Pudgy's World</a> 2005-08-18 16:58 <a href="http://www.blogjava.net/Pudgy/archive/2005/08/18/10449.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>