PHP - Manual: MongoLog
2025-10-25
(PECL mongo >=1.2.3)
Logging can be used to get detailed information about what the driver is doing. Logging is disabled by default, but this class allows you to activate specific levels of logging for various parts of the driver. Some examples:
<?php
// print every log message possible
MongoLog::setLevel(MongoLog::ALL); // all log levels
MongoLog::setModule(MongoLog::ALL); // all parts of the driver
// print significant events about replica set failover
MongoLog::setLevel(MongoLog::INFO);
MongoLog::setModule(MongoLog::RS);
// print info- and diagnostic-level events for replica sets and connections
MongoLog::setLevel(MongoLog::INFO|MongoLog::FINE);
MongoLog::setModule(MongoLog::RS|MongoLog::CON);
?>
Note:
By default, MongoLog emits all log messages as PHP notices. Depending on the SAPI you use, messages may be sent to stderr (for CLI) or the web server's error log. If, after configuring MongoLog, log messages are not appearing as expected, ensure that the
E_NOTICEbit is included in error_reporting and that display_errors is on.
These constants can be used by both MongoLog::setLevel() and MongoLog::setModule().
MongoLog::NONEMongoLog::ALLThese constants can be used by MongoLog::setLevel().
MongoLog::WARNINGMongoLog::INFOMongoLog::FINEThese constants can be used by MongoLog::setModule().
MongoLog::CONMongoLog::IOMongoLog::PARSEMongoLog::POOLMongoLog::RS.
MongoLog::RSMongoLog::SERVERMongoLog::RS.
| 版本 | 说明 |
|---|---|
| 1.3.0 |
Added MongoLog::CON and deprecated
MongoLog::POOL and
MongoLog::SERVER.
|