Why is the logger (logger) declared as static final

Source: Internet
Author: User
Tags log4j
(1) For the consideration of resource utilization, Logger's construction method parameter is class, which determines that logger is based on class structure to distinguish log, so a class as long as a logger can be, so static
(2) final represents a programming habit, indicating that the logger of the class only records the information of the class, otherwise the log will not be able to provide a convincing record


By the way, stick to one of your own log4j.properties:
Log4j.rootlogger=info,console

Log4j.appender.console=org.apache.log4j.consoleappender
Log4j.appender.console.target=system.out
log4j.appender.console.layout=org.apache.log4j.patternlayout
LOG4J.APPENDER.CONSOLE.LAYOUT.CONVERSIONPATTERN=[%P][%D{YYYY-MM-DD Hh\:mm\:ss,sss}][%c{1}:%l]%m%n

Log4j.appender.onefile=org.apache.log4j.rollingfileappender 
log4j.appender.onefile.file=. /test.log
log4j.appender.onefile.maxfilesize=10mb
log4j.appender.onefile.threshold=all
Log4j.appender.onefile.layout=org.apache.log4j.patternlayout
LOG4J.APPENDER.ONEFILE.LAYOUT.CONVERSIONPATTERN=[%P][%D{YYYY-MM-DD hh\:mm\:ss,sss}] [%c{1}:%L]%m%n

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.