How to log context information to logger (session id, user, ...)

You are viewing revision #3 of this wiki article.
This version may not be up to date with the latest version.
You may want to view the differences to the latest version or see the changes made in this revision.

« previous (#2)next (#4) »

Logging context information (session, user, ...) to the logfile can be of great help tracking down problems with specific users.

This requires Yii 1.0.6

config/main.php

<?php
return array(
    // ... 
    'preload'=>array('log', 'session'),

    // ...
    'components'=>array(
        // ... 
        'log'=>array(
        'class'=>'CLogRouter',
        'routes'=>array(
            array(
                'class'=>'CWebLogRoute',
                'levels'=>'trace,info,error,warning',
                'filter' => array(
                    'class' => 'CLogFilter',
                    'prefixSession' => true,
                    'prefixUser' => false,
                    'logUser' => false,
                    'logVars' => array(),
                ),
            ),
        ),

You could also extend CLogFilter to do your own log message decoration.

Links

Russian Version

2 0
5 followers
Viewed: 24 188 times
Version: Unknown (update)
Category: Tutorials
Tags: Logging
Written by: olafure
Last updated by: ajsharma
Created on: Jun 5, 2009
Last updated: 11 years ago
Update Article

Revisions

View all history

Related Articles