Home > Backend Development > PHP Tutorial > log4php配置文件范例

log4php配置文件范例

WBOY
Release: 2016-06-13 13:08:53
Original
1038 people have browsed it

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
Copy after login


这样就可以通过建立多个配置文件,方便为每一个产品或者模块采用不同的配置,当然生成的日志目录也可以灵活管理。

调用如下:
include_once('log4php/Logger.php');
Logger::configure("product.cam.properties");
$logger = Logger::getLogger('cam');
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template