The sfMongoDBLogger uses a MongoDB to log messages. It utilizes several features of the mongo extension and MongoDB itself.
There are several configuration options available.
The basic configuration items to initialize a working MongoDB connection.
- host, defaults to configured PHP host
- port, defaults to configured PHP port
These two options are required in order to get the logger working:
If you want to connect to the MongoDB as an authenticated user, you can put the information in these items. To disable this feature, configure it with false (default).
MongoDB write options
By default the write operations on MongoDB are not synchronous. This implies that not all data sent to the server will actually be written to the persistent, in case something bad happens. However there are options to force the server to actually persist the data before returning the result state.
save takes three keys. (see http://docs.php.net/manual/en/mongocollection.insert.php)
Each of these options default to the extensions default settings, but can be overwritten on a per logger basis. This way you can add an error logger with synchronous write operations while having a debug logger without.
MongoDB create collection options
By default MongoDB creates a collection on-the-fly where needed. If you want to create a collection with different parameters than the default ones, e.g. a capped collection, you can specify these options using the
This option takes these keys. (see http://docs.php.net/manual/en/mongodb.createcollection.php)
logger: class: sfMongoDBLogger param: level: debug # The MongoDB server host: <?php echo Mongo::DEFAULT_HOST . "\n" ?> port: <?php echo Mongo::DEFAULT_PORT . "\n" ?> database: ~ collection: ~ # Authentication information username: false password: false # Options passed when inserting a new document save: safe: false fsync: false timeout: <?php echo MongoCursor::$timeout . "\n" ?> # Options to create the collection. create: capped: false size: 0 max: 0
This event passes the document (associative array: message, priority) to be inserted into MongoDB for further modification.
The following listeners are bundled and can be connected to this event.