[
https://issues.apache.org/jira/browse/LOG4PHP-208?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13687024#comment-13687024
]
VladimĂr Gorej commented on LOG4PHP-208:
----------------------------------------
There is already an opened issue for this type of feature here:
https://issues.apache.org/jira/browse/LOG4PHP-204
MDC context will be used to supply extra data for logging events. Now that
there is an official future request for this, I'll do my best to implement it
as soon as possible. Decorating logging event with additional data will look
like this:
# Decorate one event.
LoggerMDC::put('extra_data', 'extra data');
$logger = Logger::getRootLogger();
$logger->debug("Decorating DEBUG event with extra data");
LoggerMDC::remove('extra_data'); # or LoggerMDC::clear();
# Decorate all events with extra data
LoggerMDC::put('request_ip', $_SERVER['REMOTE_ADDR']);
$logger = Logger::getRootLogger();
$logger->debug("Decorating DEBUG event with user IP address");
$logger->info("Decorating DEBUG event with user IP address");
> Add ability to pass more information to the MongoDB logger
> -----------------------------------------------------------
>
> Key: LOG4PHP-208
> URL: https://issues.apache.org/jira/browse/LOG4PHP-208
> Project: Log4php
> Issue Type: Improvement
> Components: Code
> Reporter: Brian Thibault
> Labels: mongo
> Original Estimate: 8h
> Remaining Estimate: 8h
>
> I'm using my logger in a distributed environment and really need another
> available field for MongoDB, called jobID, so I can tie a queued job to the
> logged event.
> I think it could be handled with something like:
> {code}
> public function log( LoggerLevel $level, $message, $throwable = null, $extras
> = array('jobId' => new MongoId('foo123'), 'foo' => 'bar') )
> {code}
> {code}
> {
> _id: ObjectId("51c08aca162d280300000000"),
> jobId: ObjectId("foo123"),
> foo: 'bar',
> timestamp: ISODate("2013-06-18T16:28:58.017Z"),
> level: "ERROR",
> thread: 3,
> message: "User: xxx has no API credentials.",
> loggerName: "main",
> fileName: "/app/admin/protected/components/xxx.php",
> method: "_setApi",
> lineNumber: 86,
> className: "xxx"
> }
> {code}
> I tried to extend the Logger package to build this in, but I found it rather
> un-extensible. I ended up extending pretty much all the files, which at that
> point, may as well just edit the core files.
> Thanks
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira