This post describes steps required to enable logging in Symfony project in production enviroment.
By default logging is disabled in prod enviroment, and if you want to enable it, you need to edit settings.yml and factories.yml files in your app directory.
In settings.yml set parameter logging_enabled to true:
# /app/frontend/config/settings.yml prod: .settings: no_script_name: true logging_enabled: true
In factories.yml change logger class param to sfAggregateLogger:
# /app/frontend/config/factories.yml prod: logger: class: sfAggregateLogger param: level: err loggers: ~
Note that param level is set to err. This means that only error level messages will be written to log file. If you have a high traffic web service running, this may be the best setting to use.
Important: Although it may appear logical to use sfFileLogger class, this causes error 500 in my project.
If you’re having problems with logging in production when using logger fron sfContext like this:
sfContext::getInstance()->getLogger()->err('My Error Message');
you may want to customize factories.yml further to explicitly specify what type of logger is used :
# /app/frontend/config/factories.yml prod: logger: class: sfAggregateLogger param: level: err loggers: sf_file_debug: class: sfFileLogger param: level: err file: %SF_LOG_DIR%/%SF_APP%_%SF_ENVIRONMENT%.log
Facebook
Rss feed
Twitter
Regarding the 500 error message from your project: did you checked the permissions for the /log folder from your app?
The permissions were set by default on initial project setup, and there were no issues with any other log setup, so there was no reason to belive that there was a problem with the permissions.