Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple log files in symfony

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
like image 815
Mike Avatar asked Dec 18 '09 15:12

Mike


2 Answers

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!");
like image 123
WayFarer Avatar answered Sep 21 '22 13:09

WayFarer


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
like image 32
Davide Avatar answered Sep 19 '22 13:09

Davide