PHPackages                             sterlingdesign/global-logging - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. sterlingdesign/global-logging

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

sterlingdesign/global-logging
=============================

Implementation of Psr\\Log\\LoggerAwareInterface with Global functions for logging and de-coupling from any implementation

2.1.0(8mo ago)0181MITPHPPHP &gt;=7.1

Since Dec 17Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/sterlingdesign/global-logging)[ Packagist](https://packagist.org/packages/sterlingdesign/global-logging)[ RSS](/packages/sterlingdesign-global-logging/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (8)Dependencies (1)Versions (9)Used By (1)

sterlingdesign/global-logging
-----------------------------

[](#sterlingdesignglobal-logging)

### Overview

[](#overview)

This package provides global functions for logging and de-couples from any and all PSR-3 implementations. Instead of storing or injecting a PSR-3 logger interface in each class where logging functionality is needed, the Logger is stored in a global, single instance object that can be configured at startup/bootstrap globally.

The global functions can be called by any function or class member (including static class members). If configured, the globally configured logger is used, otherwise the native php `error_log()` function is used.

For more about PSR-3, see

### Installation

[](#installation)

`composer require sterlingdesign/global-logging`

The installation includes a test file so that you can verify the installation and also experiment with operation and configuration. The script is meant to be run from the command line, for example:

`php -f vendor/sterlingdesign/global-logging/test/test-global-logging-cli.php`

### Log Target Configuration

[](#log-target-configuration)

In the simplest case, the Log functions (see **Global Functions** below) can be used **without** configuring any PSR-3 log target. If a PSR-3 logger has not been configured, the built-in PHP function `error_log($message, 0)` is used to send the message to PHP's system logger (see ).

> **NOTE**: all LogXXXX calls are sent ONLY to the php system log unless you configure another PSR-3 Logger (see below). If your application requires Email or SMS notification of critical errors, configure one of the many logger's available with that capability, such as monolog

If your application uses a PSR-3 compliant logging facility, such as 'monolog', you can create an instance of that logger and set that object as the global target. If a PSR-3 logger has been configured, that logger is used by all LogXXXX functions *instead of* the native PHP `error_log()` function.

*your\_bootstrap\_file.php*

```
