The documentation you are viewing is for an older version of this component.
Switch to the latest (v4) version.
Loggers must have at least one writer.
A writer is an object that inherits from Laminas\Log\Writer\AbstractWriter
. A writer's responsibility is to record log data to a storage backend. (from laminas-log's writer documentation)
You can separate logs into multiple files using writers and filters. For example warnings.log, errors.log, all_messages.log.
The following is the simplest example to write all log messages to /log/dk.log
return [
'dot_log' => [
'loggers' => [
'my_logger' => [
'writers' => [
'FileWriter' => [
'name' => 'FileWriter',
'priority' => \Laminas\Log\Logger::ALERT, // this is equal to 1
'options' => [
'stream' => __DIR__ . '/../../log/dk.log',
],
],
],
]
],
],
];
FileWriter
key is optional, otherwise the writers array would be enumerative instead of associative.name
key is a developer-provided name for that writer, the writer name key is mandatory.The priority
key does not affect the errors that are written. It is a way to organize writers, for example:
The most important things to write in the file, the sql or e-mail are usually fails because the servers can be external and offline, but the file is on the same server.
The priority
key is optional.
The key stream
is required only if writing into streams/files.