views:

218

answers:

3

I'd like to set up an additional log file in symfony, so that some messages (payment processing in my case) would go to a different file from the rest of symfony. Is it possible? Here's my current log configuration from factories.yml:

all:
  logger:
    param:
      level: debug
      loggers:
        sf_file_debug:
          param:
            level: notice
            file: /var/log/symfony/%SF_ENVIRONMENT%/%SF_APP%.log
A: 

Check this plugin: http://www.symfony-project.org/plugins/sfAdvancedLoggerPlugin/0%5F2%5F0 You can do lots of logging things with it.

nacmartin
A: 
all:
  logger:
    class:   sfAggregateLogger
    param:
      level:   debug
      loggers:
        sf_file_debug:
          class: sfFileLogger
          param:
            level: debug
            file: %SF_LOG_DIR%/%SF_APP%_%SF_ENVIRONMENT%.log
        sf_file_debug_additional:
          class: sfFileLogger
          param:
            level: debug
            file: %SF_LOG_DIR%/%SF_APP%_%SF_ENVIRONMENT%_additional.log
daviweb
A: 

daviweb's solution will log messages to both log files,

new separate logger can be created using code:

$logPath = sfConfig::get('sf_log_dir').'/your-custom.log';
$custom_logger = new sfFileLogger(new sfEventDispatcher(), array('file' => $logPath));

$custom_logger->info("My log message!");
WayFarer