PHPackages                             phpgt/logger - 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. phpgt/logger

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

phpgt/logger
============

PSR-3 logger and implementation.

v1.1.0(2mo ago)04.5k↓79.9%[2 PRs](https://github.com/PhpGt/Logger/pulls)1MITPHPPHP &gt;=8.1CI passing

Since Sep 21Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/PhpGt/Logger)[ Packagist](https://packagist.org/packages/phpgt/logger)[ GitHub Sponsors](https://github.com/sponsors/PhpGt)[ RSS](/packages/phpgt-logger/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (2)Versions (8)Used By (1)

Simple logger for PHP applications.
===================================

[](#simple-logger-for-php-applications)

Start logging with zero configuration. By default, the logger works as a static singleton - `Log::error("You can't do that");` is all you need to get started. When you need to, you can configure the logger to send logs to different file/socket sources.

The aim of this library is minimalism. There are no plans to implement more logging sources than files and sockets. This simplifies the code into having a single responsibility, but remains modular to hook up to external scripts that handle logging to email addresses, Slack messages, AWS SQS, databases, etc.

Log levels
----------

[](#log-levels)

This library implements the [PSR-3 interface](https://www.php-fig.org/psr/psr-3/). This means that throughout your code, you can decide to log at the levels listed below, and your environment can decide the minimum log level to report. For instance, it would probably be too verbose to log debug information on a production server. This is consistent with the [Syslog protocol](https://tools.ietf.org/html/rfc5424).

- `debug` - Detailed debugging information.
- `info` - Interesting events.
- `notice` - Normal, but significant events.
- `warning` - Exceptional occurrences that are not errors.
- `error` - Runtime errors that do not require immediate action but should typically be logged and monitored.
- `critical` - Critical conditions.
- `alert` - Action must be taken immediately.
- `emergency` - System is unusable.

Static usage
------------

[](#static-usage)

[Static classes should only be used when truly stateless](https://github.com/PhpGt/StyleGuide/blob/master/classes/members.md#classes-should-have-all-or-no-static-members). Logging is one example of a class that has no side effects on the running program, so the primary usage expectation is to use static methods of the `Log` class to perform logging.

It would be unnecessary to require passing an instance of the `Log` class around throughout all classes of your program, and it would be too opinionated to require the use of a dependency injection framework everywhere that logging is possible.

However, certain programs require advanced logging features that are only satisfiable with instances of the `Log` class, such as having different log sources for different areas of the program. Take a look at the [examples directory](https://github.com/PhpGt/Logger/tree/master/examples) to see how instantiation can be used for this purpose.

Usage example
-------------

[](#usage-example)

```
use Gt\Logger\Log;
use Gt\Logger\LogConfig;
use Gt\Logger\LogLevel;
use Gt\Logger\LogHandler\StreamHandler;
use Gt\Logger\LogHandler\FileHandler;
use Gt\Logger\LogHandler\StdErrHandler;

// Send warnings and above to the remote socket.
LogConfig::addHandler(new StreamHandler("/example/remote.sock"), LogLevel::WARNING);
// Send all log types to the local log file.
LogConfig::addHandler(new FileHandler("/var/log/example.log"), LogLevel::DEBUG);
// Send only errors and above to STDERR.
LogConfig::addHandler(new StdErrHandler(), LogLevel::ERROR, LogLevel::EMERGENCY);
// Send lower-severity logs to STDOUT.
LogConfig::addHandler(LogConfig::getDefaultHandler(), LogLevel::DEBUG, LogLevel::WARNING);

$fileName = "name.txt";
if(file_exists($fileName)) {
        $name = trim(file_get_contents($fileName));

        if(empty($name)) {
                Log::error("Empty name loaded");
        }
        else {
                Log::info("Loaded name: $name");
        }
}
else {
        $name = "you";
        Log::info("Using default name");
}
```

Proudly sponsored by
====================

[](#proudly-sponsored-by)

[JetBrains Open Source sponsorship program](https://www.jetbrains.com/community/opensource/)

[![JetBrains logo.](https://camo.githubusercontent.com/b5639e7738c6dfae9fe3f3e20175570b7376ce2577a772e09c25c2d4f14bf86e/68747470733a2f2f7265736f75726365732e6a6574627261696e732e636f6d2f73746f726167652f70726f64756374732f636f6d70616e792f6272616e642f6c6f676f732f6a6574627261696e732e737667)](https://www.jetbrains.com/community/opensource/)

###  Health Score

49

—

FairBetter than 95% of packages

Maintenance88

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~815 days

Total

3

Last Release

62d ago

PHP version history (2 changes)v1.0.0PHP &gt;=7.4

v1.0.1PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/9e42344b91ce4b91ab57875969f67a0a6a48de570a08bc65d673b06b72fd3a3f?d=identicon)[g105b](/maintainers/g105b)

---

Top Contributors

[![g105b](https://avatars.githubusercontent.com/u/358014?v=4)](https://github.com/g105b "g105b (15 commits)")

---

Tags

logloggerlogginglogssyslog

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/phpgt-logger/health.svg)

```
[![Health](https://phpackages.com/badges/phpgt-logger/health.svg)](https://phpackages.com/packages/phpgt-logger)
```

###  Alternatives

[psr/log

Common interface for logging libraries

10.4k1.2B9.1k](/packages/psr-log)[itsgoingd/clockwork

php dev tools in your browser

5.9k27.6M94](/packages/itsgoingd-clockwork)[graylog2/gelf-php

A php implementation to send log-messages to a GELF compatible backend like Graylog2.

41838.2M137](/packages/graylog2-gelf-php)[bugsnag/bugsnag-psr-logger

Official Bugsnag PHP PSR Logger.

32132.5M2](/packages/bugsnag-bugsnag-psr-logger)[consolidation/log

Improved Psr-3 / Psr\\Log logger based on Symfony Console components.

15462.2M7](/packages/consolidation-log)[datadog/php-datadogstatsd

An extremely simple PHP datadogstatsd client

19124.6M15](/packages/datadog-php-datadogstatsd)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
