https://github.com/phlib/logger
PHP PSR-3-compatible logger
https://github.com/phlib/logger
Last synced: 5 months ago
JSON representation
PHP PSR-3-compatible logger
- Host: GitHub
- URL: https://github.com/phlib/logger
- Owner: phlib
- License: lgpl-3.0
- Created: 2015-08-10T15:42:59.000Z (almost 11 years ago)
- Default Branch: main
- Last Pushed: 2025-04-06T08:04:48.000Z (over 1 year ago)
- Last Synced: 2025-10-28T16:57:14.470Z (8 months ago)
- Language: PHP
- Homepage:
- Size: 151 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# phlib/logger
[](https://github.com/phlib/logger/actions/workflows/code-checks.yml)
[](https://codecov.io/gh/phlib/logger)
[](https://packagist.org/packages/phlib/logger)
[](https://packagist.org/packages/phlib/logger)

PHP PSR-3-compatible logger
## Install
Via Composer
``` bash
$ composer require phlib/logger
```
## Usage
Example config for a logger pool
``` php
$loggerConfig = [
'default' => [ // logger config identifier, used as facility/name in log messages
// multiple logger entries becomes a collection logger
[
// logger type (stream, gelf...)
'type' => 'stream',
// the level of log messages to include (optional)
'level' => \Psr\Log\LogLevel::ERROR,
// logger specific parameters
'path' => '/var/log/my_app.log'
],
[
'type' => 'gelf',
'level' => \Psr\Log\LogLevel::INFO,
// logger specific parameters
'host' => '127.0.0.1',
'port' => 12201
]
],
'application' => 'default', // alias to another logger config
'api' => [
'type' => 'gelf',
'host' => '127.0.0.1',
'port' => 12201
]
];
```
Creation of logger pool
``` php
$loggerPool = new \Phlib\Logger\Pool(
new \Phlib\Logger\Config($loggerConfig),
new \Phlib\Logger\Factory()
);
```
Get a logger instance
``` php
$applicationLogger = $loggerPool->getLogger('application');
// or
$applicationLogger = $loggerPool->application;
$applicationLogger->info('Logging is initialised');
```
## License
This package is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see .