How to log logs using the logger in java.util.logging

Source: Internet
Author: User
Public void init () {   log = logger.getlogger ("LoggerNewConfig");     //log.setlevel (Level.severe)//Set level   below set level messages will be blocked    //log.setlevel (Level.off) ;//Turn off log    FileHandler fileHandler = null;    try {       fileHandler = new  Filehandler ("E:/dd/log.txt",  0, 1, false);//       // Parameter 1: Specify log output file path   Parameter 2: File Maximum bytes  0 represents unlimited        //  parameter 3: Log file count can be multiple   Parameter 4: Whether to append the log after the original log, false to modify the log file instead of appending    } catch  (EXCEPTION EX)  {        ex.printstacktrace ();   &NBSP}    filehandler.setlevel (Level.finer);//Setting output level in log file     Filehandler.setformatter (New simpleformatter ());//Set Output information in plain format   default to XML)     Log.addhandler (fIlehandler);    log.setlevel (Level.finer);/set Log Level    log.severe ("highest level");    log.info ("loggernewconfig  started.");    log.warning ("This is a warning"); Log information we can not only output in the console, but also specify output to log files, the above examples can learn how to use different levels of log output and log file number of settings

        

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.