First, the program error
- Warning: Yellow Line: Warning
- Error: Resource class: System level (thread)/ Environment level (drawing)
- exception: Compile level: Exception
Run Level: Exception-RuntimeException
Second, abnormal operation
- Enter an unmatched exception: Inputmismatchexception
- Arithmetic Exceptions: ArithmeticException:/By zero
- Array subscript out- of-bounds exception: ArrayIndexOutOfBoundsException
- number Format exception: NumberFormatException
- NULL pointer exception: NullPointerException
- there is no exception to the bytecode file: ClassNotFoundException
- Wait a minute...
Third, exception handling
- Throw :throw Exception /throws declaration exception
- catch:try...catch...finally ...
- Exception class Genealogy
Iv. log files
- Create Folder Lib
- Check in the log4j jar package
- Adding a jar package to the compilation path (add tobuildpath)
- Create configuration file:log4j.properties
- Edit configuration information Open the Log4j.properties file, write in source
Log4j.rootlogger=debug, stdout,logfile
Log4j.appender.stdout=org.apache.log4j.consoleappender
Log4j.appender.stdout.target=system.err
Log4j.appender.stdout.layout=org.apache.log4j.simplelayout
Log4j.appender.logfile=org.apache.log4j.fileappender
Log4j.appender.logfile.file=jbit.log
Log4j.appender.logfile.layout=org.apache.log4j.patternlayout
log4j.appender.logfile.layout.conversionpattern=%d{yyyy-mm-dd HH:mm:ss}%l%F%p%m%n
Use
- To create a Log object property in a class that requires logging information
Import Org.apache.log4j.Logger
Public Logger log = Logger.getlogger ( class name . Class.getname ());
Log.error (String errmessage);
Log.error (String errmessage, Exception e);
Java exception handling and log4j configuration files