﻿<?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-JavaZone-随笔分类-Library</title><link>http://www.blogjava.net/MrZhujia/category/45753.html</link><description>追寻科技前沿</description><language>zh-cn</language><lastBuildDate>Sat, 31 Jul 2010 08:58:37 GMT</lastBuildDate><pubDate>Sat, 31 Jul 2010 08:58:37 GMT</pubDate><ttl>60</ttl><item><title>Receive HTTP Message via apache httpclient</title><link>http://www.blogjava.net/MrZhujia/archive/2010/07/28/327364.html</link><dc:creator>祝嘉</dc:creator><author>祝嘉</author><pubDate>Wed, 28 Jul 2010 12:27:00 GMT</pubDate><guid>http://www.blogjava.net/MrZhujia/archive/2010/07/28/327364.html</guid><wfw:comment>http://www.blogjava.net/MrZhujia/comments/327364.html</wfw:comment><comments>http://www.blogjava.net/MrZhujia/archive/2010/07/28/327364.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/MrZhujia/comments/commentRss/327364.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/MrZhujia/services/trackbacks/327364.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 使用Apache的HTTPCLIENT獲取網頁的內容&nbsp;&nbsp;<a href='http://www.blogjava.net/MrZhujia/archive/2010/07/28/327364.html'>阅读全文</a><img src ="http://www.blogjava.net/MrZhujia/aggbug/327364.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/MrZhujia/" target="_blank">祝嘉</a> 2010-07-28 20:27 <a href="http://www.blogjava.net/MrZhujia/archive/2010/07/28/327364.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Log4j的PatternLayout</title><link>http://www.blogjava.net/MrZhujia/archive/2010/07/28/327357.html</link><dc:creator>祝嘉</dc:creator><author>祝嘉</author><pubDate>Wed, 28 Jul 2010 10:50:00 GMT</pubDate><guid>http://www.blogjava.net/MrZhujia/archive/2010/07/28/327357.html</guid><wfw:comment>http://www.blogjava.net/MrZhujia/comments/327357.html</wfw:comment><comments>http://www.blogjava.net/MrZhujia/archive/2010/07/28/327357.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/MrZhujia/comments/commentRss/327357.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/MrZhujia/services/trackbacks/327357.html</trackback:ping><description><![CDATA[<p style="text-indent: 0.74cm; margin-bottom: 0.28cm;"><font face="Arial"><font size="3"><span lang="en-US">The
<code class="western">PatternLayout</code> is by far the most widely
used log4j layout. It formats logging events according to a
conversion pattern specified by the user. Conversion patterns are
composed of literal text and conversion specifiers. Literal text is
output as is. Conversion specifiers consist of the % character
followed by an optional format modifier and a mandatory conversion
character. For example, <strong>%-5p [%t]: %m%n</strong> is a conversion
pattern composed of a priority (a.k.a. level) conversion specifier
followed by the literal text " ]", followed by a thread
conversion specifier, followed by literal text "]: "
followed by a message conversion specifier and a system dependent
line separator. See <a href="http://jakarta.apache.org/log4j/docs/api/org/apache/log4j/PatternLayout.html">PatternLayout
documentation</a> for more details. </span></font></font>
</p>
<p style="text-indent: 0.74cm; margin-bottom: 0.28cm;"><font face="Arial"><font size="3"><span lang="en-US">Note
that there is no explicit separator between text and conversion
specifiers. The pattern parser knows when it has reached the end of a
conversion specifier when it reads a conversion character. In the
example above the conversion specifier <strong>%-5p</strong> means the priority
of the logging event should be left justified to a width of five
characters. The recognized conversion characters are </span></font></font>
</p>
<table border="1" cellpadding="8" cellspacing="3" width="643">
    <col width="99">
    <col width="500">
    <tbody>
        <tr>
            <th width="99">
            <p><font face="Arial"><font size="3"><span lang="en-US">Conversion Character</span></font></font></p>
            </th>
            <th width="500">
            <p><font face="Arial"><font size="3"><span lang="en-US">Effect</span></font></font></p>
            </th>
        </tr>
        <tr>
            <td width="99">
            <p align="CENTER"><font face="Arial"><font size="3"><span lang="en-US"><strong>c</strong></span></font></font></p>
            </td>
            <td width="500">
            <p style="margin-bottom: 0.5cm;"><font face="Arial"><font size="3"><span lang="en-US">Used
            to output the category of the logging event. The category
            conversion specifier can be optionally followed by <em>precision
            specifier</em>, that is a decimal constant in brackets. </span></font></font>
            </p>
            <p style="margin-bottom: 0.5cm;"><font face="Arial"><font size="3"><span lang="en-US">If
            a precision specifier is given, then only the corresponding number
            of right most components of the category name will be printed. By
            default the category name is printed in full. </span></font></font>
            </p>
            <p><font face="Arial"><font size="3"><span lang="en-US">For example, for the
            category name "a.b.c" the pattern <strong>%c{2}</strong> will
            output "b.c". </span></font></font>
            </p>
            </td>
        </tr>
        <tr>
            <td width="99">
            <p align="CENTER"><font face="Arial"><font size="3"><span lang="en-US"><strong>C</strong></span></font></font></p>
            </td>
            <td width="500">
            <p style="margin-bottom: 0.5cm;"><font face="Arial"><font size="3"><span lang="en-US">Used
            to output the fully qualified class name of the caller issuing the
            logging request. This conversion specifier can be optionally
            followed by <em>precision specifier</em>, that is a decimal
            constant in brackets. </span></font></font>
            </p>
            <p style="margin-bottom: 0.5cm;"><font face="Arial"><font size="3"><span lang="en-US">If
            a precision specifier is given, then only the corresponding number
            of right most components of the class name will be printed. By
            default the class name is output in fully qualified form. </span></font></font>
            </p>
            <p style="margin-bottom: 0.5cm;"><font face="Arial"><font size="3"><span lang="en-US">For
            example, for the class name "org.apache.xyz.SomeClass",
            the pattern <strong>%C{1}</strong> will output "SomeClass". </span></font></font>
            </p>
            <p><font face="Arial"><font size="3"><span lang="en-US"><strong>WARNING</strong> Generating
            the caller class information is slow. Thus, use should be avoided
            unless execution speed is not an issue. </span></font></font>
            </p>
            </td>
        </tr>
        <tr>
            <td width="99">
            <p align="CENTER"><font face="Arial"><font size="3"><span lang="en-US"><strong>d</strong></span></font></font></p>
            </td>
            <td width="500">
            <p style="margin-bottom: 0.5cm;"><font face="Arial"><font size="3"><span lang="en-US">Used
            to output the date of the logging event. The date conversion
            specifier may be followed by a <em>date format specifier</em>
            enclosed between braces. For example, <strong>%d{HH:mm:ss,SSS}</strong> or
            <strong>%d{dd&nbsp;MMM&nbsp;yyyy&nbsp;HH:mm:ss,SSS}</strong>. If no date
            format specifier is given then ISO8601 format is assumed. </span></font></font>
            </p>
            <p style="margin-bottom: 0.5cm;"><font face="Arial"><font size="3"><span lang="en-US">The
            date format specifier admits the same syntax as the time pattern
            string of the <code class="western"><a href="http://java.sun.com/j2se/1.3/docs/api/java/text/SimpleDateFormat.html?is-external=true">SimpleDateFormat</a></code>.
            Although part of the standard JDK, the performance of
            <code class="western">SimpleDateFormat</code> is quite poor. </span></font></font>
            </p>
            <p style="margin-bottom: 0.5cm;"><font face="Arial"><font size="3"><span lang="en-US">For
            better results it is recommended to use the log4j date formatters.
            These can be specified using one of the strings "ABSOLUTE",
            "DATE" and "ISO8601" for specifying
            <code class="western"><a href="http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/helpers/AbsoluteTimeDateFormat.html">AbsoluteTimeDateFormat</a></code>,
            <code class="western"><a href="http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/helpers/DateTimeDateFormat.html">DateTimeDateFormat</a></code>
            and respectively <code class="western"><a href="http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/helpers/ISO8601DateFormat.html">ISO8601DateFormat</a></code>.
            For example, <strong>%d{ISO8601}</strong> or <strong>%d{ABSOLUTE}</strong>. </span></font></font>
            </p>
            <p><font face="Arial"><font size="3"><span lang="en-US">These dedicated date
            formatters perform significantly better than <code class="western"><a href="http://java.sun.com/j2se/1.3/docs/api/java/text/SimpleDateFormat.html?is-external=true">SimpleDateFormat</a></code>.
            </span></font></font>
            </p>
            </td>
        </tr>
        <tr>
            <td width="99">
            <p align="CENTER"><font face="Arial"><font size="3"><span lang="en-US"><strong>F</strong></span></font></font></p>
            </td>
            <td width="500">
            <p style="margin-bottom: 0.5cm;"><font face="Arial"><font size="3"><span lang="en-US">Used
            to output the file name where the logging request was issued. </span></font></font>
            </p>
            <p><font face="Arial"><font size="3"><span lang="en-US"><strong>WARNING</strong> Generating
            caller location information is extremely slow and should be
            avoided unless execution speed is not an issue. </span></font></font>
            </p>
            </td>
        </tr>
        <tr>
            <td width="99">
            <p align="CENTER"><font face="Arial"><font size="3"><span lang="en-US"><strong>l</strong></span></font></font></p>
            </td>
            <td width="500">
            <p style="margin-bottom: 0.5cm;"><font face="Arial"><font size="3"><span lang="en-US">Used
            to output location information of the caller which generated the
            logging event. </span></font></font>
            </p>
            <p style="margin-bottom: 0.5cm;"><font face="Arial"><font size="3"><span lang="en-US">The
            location information depends on the JVM implementation but usually
            consists of the fully qualified name of the calling method
            followed by the callers source the file name and line number
            between parentheses. </span></font></font>
            </p>
            <p><font face="Arial"><font size="3"><span lang="en-US">The location information
            can be very useful. However, its generation is <em>extremely</em>
            slow and should be avoided unless execution speed is not an issue.
            </span></font></font>
            </p>
            </td>
        </tr>
        <tr>
            <td width="99">
            <p align="CENTER"><font face="Arial"><font size="3"><span lang="en-US"><strong>L</strong></span></font></font></p>
            </td>
            <td width="500">
            <p style="margin-bottom: 0.5cm;"><font face="Arial"><font size="3"><span lang="en-US">Used
            to output the line number from where the logging request was
            issued. </span></font></font>
            </p>
            <p><font face="Arial"><font size="3"><span lang="en-US"><strong>WARNING</strong> Generating
            caller location information is extremely slow and should be
            avoided unless execution speed is not an issue. </span></font></font>
            </p>
            </td>
        </tr>
        <tr>
            <td width="99">
            <p align="CENTER"><font face="Arial"><font size="3"><span lang="en-US"><strong>m</strong></span></font></font></p>
            </td>
            <td width="500">
            <p><font face="Arial"><font size="3"><span lang="en-US">Used to output the
            application supplied message associated with the logging event.</span></font></font></p>
            </td>
        </tr>
        <tr>
            <td width="99">
            <p align="CENTER"><font face="Arial"><font size="3"><span lang="en-US"><strong>M</strong></span></font></font></p>
            </td>
            <td width="500">
            <p style="margin-bottom: 0.5cm;"><font face="Arial"><font size="3"><span lang="en-US">Used
            to output the method name where the logging request was issued. </span></font></font>
            </p>
            <p><font face="Arial"><font size="3"><span lang="en-US"><strong>WARNING</strong> Generating
            caller location information is extremely slow and should be
            avoided unless execution speed is not an issue. </span></font></font>
            </p>
            </td>
        </tr>
        <tr>
            <td width="99">
            <p align="CENTER"><font face="Arial"><font size="3"><span lang="en-US"><strong>n</strong></span></font></font></p>
            </td>
            <td width="500">
            <p style="margin-bottom: 0.5cm;"><font face="Arial"><font size="3"><span lang="en-US">Outputs
            the platform dependent line separator character or characters. </span></font></font>
            </p>
            <p><font face="Arial"><font size="3"><span lang="en-US">This conversion character
            offers practically the same performance as using non-portable line
            separator strings such as "\n", or "\r\n".
            Thus, it is the preferred way of specifying a line separator. </span></font></font>
            </p>
            </td>
        </tr>
        <tr>
            <td width="99">
            <p align="CENTER"><font face="Arial"><font size="3"><span lang="en-US"><strong>p</strong></span></font></font></p>
            </td>
            <td width="500">
            <p><font face="Arial"><font size="3"><span lang="en-US">Used to output the
            priority of the logging event.</span></font></font></p>
            </td>
        </tr>
        <tr>
            <td width="99">
            <p align="CENTER"><font face="Arial"><font size="3"><span lang="en-US"><strong>r</strong></span></font></font></p>
            </td>
            <td width="500">
            <p><font face="Arial"><font size="3"><span lang="en-US">Used to output the number
            of milliseconds elapsed from the construction of the layout until
            the creation of the logging event.</span></font></font></p>
            </td>
        </tr>
        <tr>
            <td width="99">
            <p align="CENTER"><font face="Arial"><font size="3"><span lang="en-US"><strong>t</strong></span></font></font></p>
            </td>
            <td width="500">
            <p><font face="Arial"><font size="3"><span lang="en-US">Used to output the name
            of the thread that generated the logging event.</span></font></font></p>
            </td>
        </tr>
        <tr>
            <td width="99">
            <p align="CENTER"><font face="Arial"><font size="3"><span lang="en-US"><strong>x</strong></span></font></font></p>
            </td>
            <td width="500">
            <p><font face="Arial"><font size="3"><span lang="en-US">Used to output the NDC
            (nested diagnostic context) associated with the thread that
            generated the logging event. </span></font></font>
            </p>
            </td>
        </tr>
        <tr>
            <td width="99">
            <p align="CENTER"><font face="Arial"><font size="3"><span lang="en-US"><strong>X</strong></span></font></font></p>
            </td>
            <td width="500">
            <p style="margin-bottom: 0.5cm;"><font face="Arial"><font size="3"><span lang="en-US">Used
            to output the MDC (mapped diagnostic context) associated with the
            thread that generated the logging event. The <strong>X</strong> conversion
            character <em>must</em> be followed by the key for the map placed
            between braces, as in <strong>%X{clientNumber}</strong> where <code class="western">clientNumber</code>
            is the key. The value in the MDC corresponding to the key will be
            output.</span></font></font></p>
            <p><font face="Arial"><font size="3"><span lang="en-US">See <code class="western"><a href="http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/MDC.html">MDC</a></code>
            class for more details. </span></font></font>
            </p>
            </td>
        </tr>
        <tr>
            <td width="99">
            <p align="CENTER"><font face="Arial"><font size="3"><span lang="en-US"><strong>%</strong></span></font></font></p>
            </td>
            <td width="500">
            <p><font face="Arial"><font size="3"><span lang="en-US">The sequence %% outputs a
            single percent sign. </span></font></font>
            </p>
            </td>
        </tr>
    </tbody>
</table>
<p style="text-indent: 0.74cm; margin-bottom: 0.28cm;"><font face="Arial"><font size="3"><span lang="en-US">By
default the relevant information is output as is. However, with the
aid of format modifiers it is possible to change the minimum field
width, the maximum field width and justification. </span></font></font>
</p>
<p style="text-indent: 0.74cm; margin-bottom: 0.28cm;"><font face="Arial"><font size="3"><span lang="en-US">The
optional format modifier is placed between the percent sign and the
conversion character. </span></font></font>
</p>
<p style="text-indent: 0.74cm; margin-bottom: 0.28cm;"><font face="Arial"><font size="3"><span lang="en-US">The
first optional format modifier is the <em>left justification flag</em>
which is just the minus (-) character. Then comes the optional
<em>minimum field width</em> modifier. This is a decimal constant
that represents the minimum number of characters to output. If the
data item requires fewer characters, it is padded on either the left
or the right until the minimum width is reached. The default is to
pad on the left (right justify) but you can specify right padding
with the left justification flag. The padding character is space. If
the data item is larger than the minimum field width, the field is
expanded to accommodate the data. The value is never truncated. </span></font></font>
</p>
<p style="text-indent: 0.74cm; margin-bottom: 0.28cm;"><font face="Arial"><font size="3"><span lang="en-US">This
behavior can be changed using the <em>maximum field width</em>
modifier which is designated by a period followed by a decimal
constant. If the data item is longer than the maximum field, then the
extra characters are removed from the <em>beginning</em> of the data
item and not from the end. For example, it the maximum field width is
eight and the data item is ten characters long, then the first two
characters of the data item are dropped. This behavior deviates from
the printf function in C where truncation is done from the end. </span></font></font>
</p>
<img src ="http://www.blogjava.net/MrZhujia/aggbug/327357.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/MrZhujia/" target="_blank">祝嘉</a> 2010-07-28 18:50 <a href="http://www.blogjava.net/MrZhujia/archive/2010/07/28/327357.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Apache Log4j 学习笔记</title><link>http://www.blogjava.net/MrZhujia/archive/2010/05/15/321033.html</link><dc:creator>祝嘉</dc:creator><author>祝嘉</author><pubDate>Sat, 15 May 2010 05:19:00 GMT</pubDate><guid>http://www.blogjava.net/MrZhujia/archive/2010/05/15/321033.html</guid><wfw:comment>http://www.blogjava.net/MrZhujia/comments/321033.html</wfw:comment><comments>http://www.blogjava.net/MrZhujia/archive/2010/05/15/321033.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/MrZhujia/comments/commentRss/321033.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/MrZhujia/services/trackbacks/321033.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: ApacheLogging Project Homepage: http://logging.apache.orgLog4j的类图&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;         Logger    - 日志写出器，供程序员输出日志信息                        Appender  ...&nbsp;&nbsp;<a href='http://www.blogjava.net/MrZhujia/archive/2010/05/15/321033.html'>阅读全文</a><img src ="http://www.blogjava.net/MrZhujia/aggbug/321033.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/MrZhujia/" target="_blank">祝嘉</a> 2010-05-15 13:19 <a href="http://www.blogjava.net/MrZhujia/archive/2010/05/15/321033.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>