I’ve managed to get a site up and running with the Zend Framework, everything is logging nicely to FireBug/FirePHP so next step was to log to the DB. I also wanted to log some additional information using the framework such as user agent, date and time, get and post variables. So to extend the manual a little here’s what I did:
// Set up logging to DB
$db = Zend_Registry::get('dbAdapters');
$db = $db['general'];
$columnMapping = array( 'priority' => 'priority',
'message' => 'message',
'datetime' => 'timestamp',
'get_vars' => 'get_vars',
'post_vars' => 'post_vars',
'site' => 'site'
$writerDb = new Zend_Log_Writer_Db($db, 'error_logging', $columnMapping);
$logger = new Zend_Log($writerDb);
Where the array keys in $columnMapping are my column names. ‘Priority’ and ‘message’ are understood by Zend_Log_Writers but the additional fields were added to give me some additional information.
Obviously this assumes that you have logging working using one of the other writers first :)
Liked this post? Follow this blog to get more.
Leave a Reply
You must be logged in to post a comment.