log4php configuration File Instance
Recently a project intends to introduce log4php as a project log system, but found that the official explanation of the configuration file is too broad, not good understanding, engaged for two hours, a more flexible configuration file, share to everyone, the overall structure is as follows:
File name: product.cam.properties
File contents:
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
This makes it easy to configure different configurations for each product or module by creating multiple profiles, and of course the resulting log directory can be managed flexibly.
The call is as follows:
Include_once (' log4php/logger.php '); Logger::configure ("Product.cam.properties"); $logger = Logger::getlogger (' cam ');