1

I am using Zend logger as following :-

$columnMapping = array('message' => 'message', 'created_at' => 'timestamp');
$writer = new Zend_Log_Writer_Db($dbAdapater, 'log', $columnMapping);
$logger = new Zend_Log($writer);
$logger->info('Sample log data');

Now if I want to bind more fields which are not defined as default (as we can see in $columnMapping array), e.g. user_name, user_type etc, then what should I do?

To be simple I want to achieve following:-

$columnMapping = array('user_defined_field1' => 'user_defined_val_1');
$writer = new Zend_Log_Writer_Db($dbAdapater, 'log', $columnMapping);
$logger = new Zend_Log($writer);
$logger->info('Sample log data');

Please suggest.

1 Answer 1

1

Logger definition:

$columnMapping = array(
    'message' => 'message',
    'user_defined_field1' => 'user_defined_field1');
$writer = new Zend_Log_Writer_Db($dbAdapater, 'log', $columnMapping);
$logger = new Zend_Log($writer);

When 'user_defined_val1' data is available, call setEventItem() function:

$logger->setEventItem('user_defined_field1', 'user_defined_val1');
$logger->info('Sample log data');

More detail:

http://framework.zend.com/manual/en/zend.log.overview.html - Understanding Log events

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.