-
Notifications
You must be signed in to change notification settings - Fork 0
Cookbook
floriansemm edited this page Jun 22, 2012
·
7 revisions
`app/config.yml:
fs_log4_php:
appenders:
debug_file:
class: LoggerAppenderRollingFile
layout:
class: LoggerLayoutPattern
params:
file: %kernel.root_dir%/logs/debug.log
MaxFileSize: 1000KB
MaxBackupIndex: 5
error_file:
class: LoggerAppenderFile
layout:
class: LoggerLayoutPattern
params:
file: %kernel.root_dir%/logs/error.log
threshold: error
info_file:
class: LoggerAppenderFile
layout:
class: LoggerLayoutPattern
params:
file: %kernel.root_dir%/logs/info.log
threshold: info
rootLogger:
level: DEBUG
appenders: [ debug_file, error_file, info_file ]`
This configuration logs the different log-events (error, info, debug) in different files.
`app/config.yml:
# ...
# see full-configuration
# ...
event_info_file:
class: LoggerAppenderFile
layout:
class: LoggerLayoutPattern
params:
file: %kernel.root_dir%/logs/event.log
filters:
events:
class: LoggerFilterStringMatch
params:
stringToMatch: event
acceptOnMatch: true
rootLogger:
level: DEBUG
appenders: [ debug_file, error_file, info_file, event_info_file ]`
This config logs all events, which fired by symfony, in a separate event.log. The key part of this config is the filters-section. Only string with the content event are allowed.
This config shows you how to setup a logger, which logs all messages in the mail.log.
`app/config.yml:
# ...
# see full-configuration
# ...
appenders:
mail_info:
class: LoggerAppenderFile
layout:
class: LoggerLayoutPattern
params:
file: %kernel.root_dir%/logs/mail.log
rootLogger:
level: DEBUG
appenders: [ mail_info ]
loggers:
mail:
level: DEBUG
appenders: [ mail_file ]
additivity: false`
To call this logger:
$ths->get('logger')->info('message', array('app'=>'mail'));