handler.html

来自「j2se5-api-zh,java文档的中文版本」· HTML 代码 · 共 616 行 · 第 1/2 页

HTML
616
字号
</TABLE><A NAME="publish(java.util.logging.LogRecord)"><!-- --></A><H3>publish</H3><PRE>public abstract void <B>publish</B>(<A HREF="LogRecord.html" title="java.util.logging 中的类">LogRecord</A>&nbsp;record)</PRE><DL><DD>发布 <tt>LogRecord</tt>。 <p>最初向 <tt>Logger</tt> 对象发出的日志请求,此请求可初始化 <tt>LogRecord</tt> 并可在此转发这一日志记录。 <p><tt>Handler</tt> 负责在必要时进行信息格式化。 格式化应该包括本地化。<P><DD><DL><DT><B>参数:</B><DD><CODE>record</CODE> - 对日志事件的描述。默认忽略空记录,并且不进行发布。</DL></DD></DL><HR><A NAME="flush()"><!-- --></A><H3>flush</H3><PRE>public abstract void <B>flush</B>()</PRE><DL><DD>刷新和缓冲输出。<P><DD><DL></DL></DD></DL><HR><A NAME="close()"><!-- --></A><H3>close</H3><PRE>public abstract void <B>close</B>()                    throws <A HREF="../../lang/SecurityException.html" title="java.lang 中的类">SecurityException</A></PRE><DL><DD>关闭 <tt>Handler</tt>,并释放所有相关的资源。 <p>Close 方法将执行 <tt>flush</tt>,然后关闭 <tt>Handler</tt>。调用 close 方法后,就不应再使用该 <tt>Handler</tt>。要么默认忽略方法调用,要么抛出运行时异常。<P><DD><DL><DT><B>抛出:</B><DD><CODE><A HREF="../../lang/SecurityException.html" title="java.lang 中的类">SecurityException</A></CODE> - 如果存在安全管理器,且调用方不具有 <tt>LoggingPermission("control")</tt>。</DL></DD></DL><HR><A NAME="setFormatter(java.util.logging.Formatter)"><!-- --></A><H3>setFormatter</H3><PRE>public void <B>setFormatter</B>(<A HREF="Formatter.html" title="java.util.logging 中的类">Formatter</A>&nbsp;newFormatter)                  throws <A HREF="../../lang/SecurityException.html" title="java.lang 中的类">SecurityException</A></PRE><DL><DD>设置 <tt>Formatter</tt>。将该 <tt>Formatter</tt> 用于格式化该 <tt>Handler</tt> 的 <tt>LogRecords</tt>。 <p>某些 <tt>Handlers</tt> 不能使用 <tt>Formatters</tt>,在此情形下将记住而不是使用 <tt>Formatter</tt>。 <p><P><DD><DL><DT><B>参数:</B><DD><CODE>newFormatter</CODE> - <tt>Formatter</tt> 将使用(不可为空)<DT><B>抛出:</B><DD><CODE><A HREF="../../lang/SecurityException.html" title="java.lang 中的类">SecurityException</A></CODE> - 如果存在安全管理器,且调用方不具有 <tt>LoggingPermission("control")</tt>。</DL></DD></DL><HR><A NAME="getFormatter()"><!-- --></A><H3>getFormatter</H3><PRE>public <A HREF="Formatter.html" title="java.util.logging 中的类">Formatter</A> <B>getFormatter</B>()</PRE><DL><DD>返回该 <tt>Handler</tt> 的 <tt>Formatter</tt>。<P><DD><DL><DT><B>返回:</B><DD><tt>Formatter</tt>(可以为空)。</DL></DD></DL><HR><A NAME="setEncoding(java.lang.String)"><!-- --></A><H3>setEncoding</H3><PRE>public void <B>setEncoding</B>(<A HREF="../../lang/String.html" title="java.lang 中的类">String</A>&nbsp;encoding)                 throws <A HREF="../../lang/SecurityException.html" title="java.lang 中的类">SecurityException</A>,                        java.io.UnsupportedEncodingException</PRE><DL><DD>设置该 <tt>Handler</tt> 所用的字符编码。 <p>应在将任何 <tt>LogRecords</tt> 写入 <tt>Handler</tt> 之前设置编码。<P><DD><DL><DT><B>参数:</B><DD><CODE>encoding</CODE> - 所支持字符编码的名称。可以为空,以表明应为默认平台编码。<DT><B>抛出:</B><DD><CODE><A HREF="../../lang/SecurityException.html" title="java.lang 中的类">SecurityException</A></CODE> - 如果存在安全管理器,且调用方不具有 <tt>LoggingPermission("control")</tt>。<DD><CODE>UnsupportedEncodingException</CODE> - 如果不支持指定的编码。</DL></DD></DL><HR><A NAME="getEncoding()"><!-- --></A><H3>getEncoding</H3><PRE>public <A HREF="../../lang/String.html" title="java.lang 中的类">String</A> <B>getEncoding</B>()</PRE><DL><DD>返回该 <tt>Handler</tt> 的字符编码。<P><DD><DL><DT><B>返回:</B><DD>编码名称。可以为空,以表明应使用默认编码。</DL></DD></DL><HR><A NAME="setFilter(java.util.logging.Filter)"><!-- --></A><H3>setFilter</H3><PRE>public void <B>setFilter</B>(<A HREF="Filter.html" title="java.util.logging 中的接口">Filter</A>&nbsp;newFilter)               throws <A HREF="../../lang/SecurityException.html" title="java.lang 中的类">SecurityException</A></PRE><DL><DD>设置 <tt>Filter</tt>,以控制该 <tt>Handler</tt> 的输出。 <P>对于 <tt>publish</tt> 的每个调用,<tt>Handler</tt> 将调用该 <tt>Filter</tt> (如果不为空),以检查是否应发布或放弃 <tt>LogRecord</tt>。<P><DD><DL><DT><B>参数:</B><DD><CODE>newFilter</CODE> - <tt>Filter</tt> 对象(可以为空)<DT><B>抛出:</B><DD><CODE><A HREF="../../lang/SecurityException.html" title="java.lang 中的类">SecurityException</A></CODE> - 如果存在安全管理器,且调用方不具有 <tt>LoggingPermission("control")</tt>。</DL></DD></DL><HR><A NAME="getFilter()"><!-- --></A><H3>getFilter</H3><PRE>public <A HREF="Filter.html" title="java.util.logging 中的接口">Filter</A> <B>getFilter</B>()</PRE><DL><DD>获得该 <tt>Handler</tt> 的当前 <tt>Filter</tt>。<P><DD><DL><DT><B>返回:</B><DD></tt>Filter</tt> 对象(可以为空)</DL></DD></DL><HR><A NAME="setErrorManager(java.util.logging.ErrorManager)"><!-- --></A><H3>setErrorManager</H3><PRE>public void <B>setErrorManager</B>(<A HREF="ErrorManager.html" title="java.util.logging 中的类">ErrorManager</A>&nbsp;em)</PRE><DL><DD>为该 Handler 定义一个 ErrorManager。 <p>如果使用该 Handler 时发生任何错误,将调用 ErrorManager 的 "error" 方法。<P><DD><DL><DT><B>参数:</B><DD><CODE>em</CODE> - 新的 ErrorManager<DT><B>抛出:</B><DD><CODE><A HREF="../../lang/SecurityException.html" title="java.lang 中的类">SecurityException</A></CODE> - 如果存在安全管理器,且调用方不具有 <tt>LoggingPermission("control")</tt>。</DL></DD></DL><HR><A NAME="getErrorManager()"><!-- --></A><H3>getErrorManager</H3><PRE>public <A HREF="ErrorManager.html" title="java.util.logging 中的类">ErrorManager</A> <B>getErrorManager</B>()</PRE><DL><DD>检索该 Handler 的 ErrorManager。<P><DD><DL><DT><B>抛出:</B><DD><CODE><A HREF="../../lang/SecurityException.html" title="java.lang 中的类">SecurityException</A></CODE> - 如果存在安全管理器,且调用方不具有 <tt>LoggingPermission("control")</tt>。</DL></DD></DL><HR><A NAME="reportError(java.lang.String, java.lang.Exception, int)"><!-- --></A><H3>reportError</H3><PRE>protected void <B>reportError</B>(<A HREF="../../lang/String.html" title="java.lang 中的类">String</A>&nbsp;msg,                           <A HREF="../../lang/Exception.html" title="java.lang 中的类">Exception</A>&nbsp;ex,                           int&nbsp;code)</PRE><DL><DD>用于向该 Handler 的 ErrorManager 报告错误的受保护便利方法。注意,该方法无需进行安全检查即可检索和使用 ErrorManager。因此,可在调用方无特权的环境下使用该方法。<P><DD><DL><DT><B>参数:</B><DD><CODE>msg</CODE> - 描述性字符串(可以为空)<DD><CODE>ex</CODE> - 异常(可以为空)<DD><CODE>code</CODE> - 在 ErrorManager 中定义的错误代码</DL></DD></DL><HR><A NAME="setLevel(java.util.logging.Level)"><!-- --></A><H3>setLevel</H3><PRE>public void <B>setLevel</B>(<A HREF="Level.html" title="java.util.logging 中的类">Level</A>&nbsp;newLevel)              throws <A HREF="../../lang/SecurityException.html" title="java.lang 中的类">SecurityException</A></PRE><DL><DD>设置日志级别,指定该 <tt>Handler</tt> 所记录的信息级别。将放弃低于该值的信息级别。  <p>其目的在于允许开发人员打开大多数日志,但是限制将信息发送到特定 <tt>Handlers</tt>。<P><DD><DL><DT><B>参数:</B><DD><CODE>newLevel</CODE> - 日志级别的新值<DT><B>抛出:</B><DD><CODE><A HREF="../../lang/SecurityException.html" title="java.lang 中的类">SecurityException</A></CODE> - 如果存在安全管理器,且调用方不具有 <tt>LoggingPermission("control")</tt>。</DL></DD></DL><HR><A NAME="getLevel()"><!-- --></A><H3>getLevel</H3><PRE>public <A HREF="Level.html" title="java.util.logging 中的类">Level</A> <B>getLevel</B>()</PRE><DL><DD>获得用于指定该 <tt>Handler</tt> 所记录信息的日志级别。将放弃低于该值的信息级别。<P><DD><DL><DT><B>返回:</B><DD>正在记录的信息级别。</DL></DD></DL><HR><A NAME="isLoggable(java.util.logging.LogRecord)"><!-- --></A><H3>isLoggable</H3><PRE>public boolean <B>isLoggable</B>(<A HREF="LogRecord.html" title="java.util.logging 中的类">LogRecord</A>&nbsp;record)</PRE><DL><DD>检查该 <tt>Handler</tt> 是否实际记录给定的 <tt>LogRecord</tt>。 <p>该方法检查 <tt>LogRecord</tt> 是否具有适当的 <tt>Level</tt>,以及是否满足任何 <tt>Filter</tt>。它也可进行其他 <tt>Handler</tt> 特定的检查,以防处理程序记录 <tt>LogRecord</tt>。如果 <tt>LogRecord</tt> 为 Null,将返回 False。 <p><P><DD><DL><DT><B>参数:</B><DD><CODE>record</CODE> - 一个 <tt>LogRecord</tt><DT><B>返回:</B><DD>如果要记录 <tt>LogRecord</tt>,则返回 true。</DL></DD></DL><!-- ========= END OF CLASS DATA ========= --><HR><!-- ======= START OF BOTTOM NAVBAR ====== --><A NAME="navbar_bottom"><!-- --></A><A HREF="#skip-navbar_bottom" title="跳过导航链接"></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_bottom_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">  <TR ALIGN="center" VALIGN="top">  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>概述</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>软件包</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>类</B></FONT>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/Handler.html"><FONT CLASS="NavBarFont1"><B>使用</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>树</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>已过时</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>索引</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>帮助</B></FONT></A>&nbsp;</TD>  </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup>&nbsp;2&nbsp;Platform<br>Standard&nbsp;Ed. 5.0</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">&nbsp;<A HREF="Formatter.html" title="java.util.logging 中的类"><B>上一个类</B></A>&nbsp;&nbsp;<A HREF="Level.html" title="java.util.logging 中的类"><B>下一个类</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">  <A HREF="../../../index.html@java_2Futil_2Flogging_2FHandler.html" target="_top"><B>框架</B></A>  &nbsp;&nbsp;<A HREF="Handler.html" target="_top"><B>无框架</B></A>  &nbsp;&nbsp;<SCRIPT type="text/javascript">  <!--  if(window==top) {    document.writeln('<A HREF="../../../allclasses-noframe.html"><B>所有类</B></A>');  }  //--></SCRIPT><NOSCRIPT>  <A HREF="../../../allclasses-noframe.html"><B>所有类</B></A></NOSCRIPT></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">  摘要:&nbsp;嵌套&nbsp;|&nbsp;字段&nbsp;|&nbsp;<A HREF="#constructor_summary">构造方法</A>&nbsp;|&nbsp;<A HREF="#method_summary">方法</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">详细信息:&nbsp;字段&nbsp;|&nbsp;<A HREF="#constructor_detail">构造方法</A>&nbsp;|&nbsp;<A HREF="#method_detail">方法</A></FONT></TD></TR></TABLE><A NAME="skip-navbar_bottom"></A><!-- ======== END OF BOTTOM NAVBAR ======= --><HR><font size="-1"><a href="../../../../../../../../../java.sun.com/cgi-bin/bugreport.cgi">提交错误或意见</a><br>有关更多的 API 参考资料和开发人员文档,请参阅 <a href="../../../../../../../../../java.sun.com/j2se/1.5.0/docs/relnotes/devdocs-vs-specs.html">Java 2 SDK SE 开发人员文档</a>。该文档包含更详细的、面向开发人员的描述,以及总体概述、术语定义、使用技巧和工作代码示例。 <p>版权所有 2004 Sun Microsystems, Inc. 保留所有权利。 请遵守<a href="../../../../../../../../../java.sun.com/j2se/1.5.0/docs/relnotes/license.html">许可证条款</a>。另请参阅<a href="../../../../../../../../../java.sun.com/docs/redist.html">文档重新分发政策</a>。</font></BODY></HTML>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?