Originally this article would like to write about how StackTrace can be lost, but now the content has become a discussion of how to deal with the problem of exception.Should not use try catch, when use? Also bothered me for a long time, as if
In the Android debugging process often appear the results of the program is not our expected results, it is necessary to add log printing debugging, see whether the call process is correct, at this time need to print the program's call stack,
Package java. Lang;Import java. Io .*;
/**** Throwable is the parent class of all errors and exceptiong.* Note that there are four constructors:* Throwable ()* Throwable (string message)* Throwable (throwable cause)* Throwable (string message,
. One of the most basic examples of using the logging framework to write a log is basically three steps
Introduction of Loggerg Class and Logger factory class
Statement Logger
Record log
Let's look at an example1. Introduction
Today, the SLF4J is logger in a synchronous package. The main purpose is to facilitate the replacement of the log implementation system later.Problem encountered: Use Thread.CurrentThread (). Getstacktrace () [1].getclassname () gets the current
Java Exception ArchitectureThorwable class for all exceptions and errors, there are two subclasses of error and exception, respectively, representing errors and exceptions.Where the exception class Exception is divided into runtime exceptions
1. One of the most basic examples of using the logging framework to write a log is basically three steps
Introduction of Loggerg Class and Logger factory class
Statement Logger
Record log
Let's look at an example1. Introduction
Because Android Systemserver has an important service, there is a software-implemented watchdog mechanism within the process to monitor whether the service is working properly in Systemserver. If more than a certain amount of time (default 30
1. Get the Java exception printstacktrace details
Usually write Java code, want to see the exception information thrown to find out the specific anomaly, we often use exception.tostring () or exception.getmessage () to get the exception information,
We must all be familiar with the log4net of the top of the name. In the project application, Log4net is often packaged two times to meet the special needs of the project. For example, the automatic logging call Method name of the log method, the
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.