phpzend-log

how to change date format in "zend_log"


How can I change date format of the Zend_Log?

Now there is date with timestamp added in front of every new log entry:
"2013-01-28T16:47:54+01:00 ... some log message ..."

But I would like to format this date like:
"Y-m-d H:i:s ... some log message ..."

My code looks like this:

class Game_Logger {

    public function __construct($val, $txt = null) {
        $writer = new Zend_Log_Writer_Stream(APPLICATION_PATH . '/../log/log.log');
        $logger = new Zend_Log($writer);
        if (is_array($val)) {
            $output = Zend_Debug::dump($val, null, false);
        } else {
            $output = $val;
        }
        if($txt){
            $output = $txt.' '.$output;
        }
        $logger->info($output);
    }

}

Solution

  • Probably this will resolve your problem:

    $logger->setTimestampFormat("H:i:s");
    but something tells me you already figured it out ;).