log4php配置文件实例
近日一个项目中打算引入log4php作为项目的日志系统,却发现官方关于配置文件的讲解太过于宽泛,不好理解,搞了两个小时,整理出一个比较灵活的配置文件,分享给大家,整体结构如下:
文件名:product.cam.properties
文件内容:
log4php.threshold = WARN log4php.rootLogger = WARN, default log4php.appender.default = LoggerAppenderDailyFile log4php.appender.default.layout = LoggerLayoutPattern log4php.appender.default.layout.ConversionPattern = "%d{ISO8601} [%p] %c: %m (at %F line %L)%n" log4php.appender.default.datePattern = Ymd log4php.appender.default.file = /app/logs/products/cam/%s.log
include_once('log4php/Logger.php'); Logger::configure("product.cam.properties"); $logger = Logger::getLogger('cam');