Log4php configuration file example

Source: Internet
Author: User
A log4php configuration file instance recently planned to introduce log4php as the project's log system, but found that the official explanation of the configuration file was too broad and hard to understand. it took two hours, sort out a flexible configuration file and share it with you. the overall structure is as follows: File name: product. cam. properties file content: log4php. log4php configuration file instance
Recently, a project planned to introduce log4php as the project's log system, but found that the official configuration file explanation was too broad and hard to understand. it took two hours, sort out a flexible configuration file and share it with you. the overall structure is as follows:
File name: product. cam. properties
File content:
Log4php. threshold = WARNlog4php. rootLogger = WARN, defaultlog4php. appender. default = LoggerAppenderDailyFilelog4php. appender. default. layout = LoggerLayoutPatternlog4php. appender. default. layout. conversionPattern = "% d {ISO8601} [% p] % c: % m (at % F line % L) % n" log4php. appender. default. datePattern = Ymdlog4php. appender. default. file =/app/logs/products/cam/% s. log


In this way, you can create multiple configuration files to facilitate different configurations for each product or module. of course, the generated log directory can also be flexibly managed.

The call is as follows:
Include_once ('log4php/Logger. php'); Logger: configure ("product. cam. properties"); $ logger = Logger: getLogger ('Cam ');

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.