log4php mdc example?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

log4php mdc example?

jan.widmer
This post has NOT been accepted by the mailing list yet.
Hi all,

I am using log4php and it is working great. Now i would like to also log some variables which are available in my method where i am logging.

I guess the mdc feature is the right thing for that, although i cannont find any example how to add a value to the MDC.

My pattern property in my config.xml looks like that:


In my php file, i have my logger:
$logDatabase = Logger::getLogger('databaseLogger');

Now how can i add my $userId variable to the MDC context to write it to the database?

Thanks for your help.
Jan
Loading...