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 ');