Java -- handler class

Source: Internet
Author: User

I have never been clear about Java handler and Android handler. Today I leave it empty. I have read the API and the source code, and I will write it at random.

The handler class in Java directly inherits from the object class. The JDK 1.6 API describes handler as follows:

Public abstract classHandlerExtends object

java.lang.Object  java.util.logging.Handler
Directly known subclass:
Memoryhandler, streamhandler

HandlerObject slaveLoggerAnd export the log information. For example, it can write the information to the console or file, send the information to the Network Log service, or forward it to the operating system log.

RunSetlevel (level. Off)To disableHandlerAnd can be executed at the appropriate levelSetlevelTo re-enable.

HandlerClassLogmanagerAttribute to setHandlerOfFilter,FormatterAndLevel. For each specificHandlerClass, see the specified document

Abstract void close ()
Close handler and release all related resources.
Abstract void flush ()
Refresh all the buffer outputs.
String getencoding ()
Returns the character encoding of the handler.
Errormanager geterrormanager ()
Obtain the errormanager of the handler.
Filter getfilter ()
Obtain the current filter of the handler.
Formatter getformatter ()
Returns the formatter of the handler.
Level getlevel ()
Obtain the log level used to specify the information recorded by the handler.
Boolean isloggable (logrecord record)
Check whether the handler actually records the given logrecord.
Abstract void publish (logrecord record)
Publish a logrecord.
Protected void reporterror (string MSG, exception ex, int code)
The protected convenience method used to report errors to the errormanager of the handler.
Void setencoding (string encoding)
Set the character encoding used by the handler.
Void seterrormanager (errormanager em)
Define an errormanager for the handler.
Void setfilter (filter newfilter)
Set filter to control the output of the handler.
Void setformatter (formatter newformatter)
Set formatter.
Void setlevel (Level newlevel)
Set the log level to specify the information level recorded by the handler.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.