Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix outdated Log Readme #16654

Merged
merged 1 commit into from Jul 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/Log/README.md
Expand Up @@ -8,26 +8,26 @@ multiple logging backends using a simple interface. With the `Log` class it is
possible to send a single message to multiple logging backends at the same time
or just a subset of them based on the log level or context.

By default, you can use Files or Syslog as logging backends, but you can use any
By default, you can use `File` or `Syslog` as logging backends, but you can use any
object implementing `Psr\Log\LoggerInterface` as an engine for the `Log` class.

## Usage

You can define as many or as few loggers as your application needs. Loggers
should be configured using `Cake\Core\Log.` An example would be:
should be configured using `Cake\Log\Log.` An example would be:

```php
use Cake\Log\Log;

// Short classname
Log::config('local', [
'className' => 'FileLog',
Log::setConfig('local', [
'className' => 'File',
'levels' => ['notice', 'info', 'debug'],
'file' => '/path/to/file.log',
]);

// Fully namespaced name.
Log::config('production', [
Log::setConfig('production', [
'className' => \Cake\Log\Engine\SyslogLog::class,
'levels' => ['warning', 'error', 'critical', 'alert', 'emergency'],
]);
Expand All @@ -36,7 +36,7 @@ Log::config('production', [
It is also possible to create loggers by providing a closure.

```php
Log::config('special', function () {
Log::setConfig('special', function () {
// Return any PSR-3 compatible logger
return new MyPSR3CompatibleLogger();
});
Expand All @@ -45,7 +45,7 @@ Log::config('special', function () {
Or by injecting an instance directly:

```php
Log::config('special', new MyPSR3CompatibleLogger());
Log::setConfig('special', new MyPSR3CompatibleLogger());
```

You can then use the `Log` class to pass messages to the logging backends:
Expand All @@ -66,8 +66,8 @@ you can limit the logging engines that receive a particular message.
```php
// Configure /logs/payments.log to receive all levels, but only
// those with `payments` scope.
Log::config('payments', [
'className' => 'FileLog',
Log::setConfig('payments', [
'className' => 'File',
'levels' => ['error', 'info', 'warning'],
'scopes' => ['payments'],
'file' => '/logs/payments.log',
Expand Down