PHPackages                             derywat/php-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. derywat/php-logging

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

derywat/php-logging
===================

Simple, extendable PHP logging library.

0.1.2(5mo ago)024MITPHP

Since Dec 11Pushed 5mo agoCompare

[ Source](https://github.com/derywat/php-logging)[ Packagist](https://packagist.org/packages/derywat/php-logging)[ RSS](/packages/derywat-php-logging/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

Simple PHP logging library.
===========================

[](#simple-php-logging-library)

Caution

LoggerInterface and classes methods are NOT STABLE until anounced.

Single target loggers
---------------------

[](#single-target-loggers)

Single target loggers allow logging to single target - file, stdOut, strErr.

### StdOutLogger &amp; StdErrLogger

[](#stdoutlogger--stderrlogger)

StdOutLogger class allows logging to stdOut. StdErrLogger class allows logging to stdErr.

```
use derywat\logging\LogLevel;
use derywat\logging\StdOutLogger;

$logger = (new StdOutLogger())->setLevel(LogLevel::INFO);

//log something...
$logger->log(LogLevel::INFO,'main process','main process example log message.');
```

### FileLogger

[](#filelogger)

FileLogger class allows logging to file.

```
use derywat\logging\FileLogger;
use derywat\logging\LogLevel;

$logger = (new FileLogger())->setLogFile('var/log/service.info.log')->setLevel(LogLevel::INFO);

//log something...
$logger->log(LogLevel::INFO,'main process','main process example log message.');
```

Multiple target loggers
-----------------------

[](#multiple-target-loggers)

### CompositeLogger

[](#compositelogger)

CompositeLogger class allows logging to multiple single target loggers.

```
use derywat\logging\CompositeLogger;
use derywat\logging\FileLogger;
use derywat\logging\LogLevel;
use derywat\logging\StdErrLogger;
use derywat\logging\StdOutLogger;

$logger = ((new CompositeLogger())

	//StdOut logger - logging levels from INFO to WARN
	->addLogger((new StdOutLogger())->setLevel(LogLevel::INFO)->setMaxLevel(LogLevel::WARN))

	//StdErr logger - logging levels from ERROR
	->addLogger((new StdErrLogger())->setLevel(LogLevel::ERROR))

	//File logger - logging levels from INFO
	->addLogger((new FileLogger())->setLogFile('var/log/service.info.log')->setLevel(LogLevel::INFO))

	//File logger - logging levels from WARN
	->addLogger((new FileLogger())->setLogFile('var/log/service.warn.log')->setLevel(LogLevel::WARN))

	//File logger - logging levels from ERROR
	->addLogger((new FileLogger())->setLogFile('var/log/service.error.log')->setLevel(LogLevel::ERROR))
);

//log something...
$logger->log(LogLevel::INFO,'main process','main process example log message.');
```

Adding loggers
--------------

[](#adding-loggers)

New loggers can be implemented by extending abstract Logger class.

```
class NewLogger extends Logger implements LoggerInterface {

	protected function _writeToLog(LogLevel $level, String $source, String $message){
		//default log line formatting defined in Logger class
		$line = $this->_formatLogLine($level,$source,$message);

		//put code writing/sending $line to log here

	}

}
```

Loggers methods
---------------

[](#loggers-methods)

### setLevel

[](#setlevel)

Sets minimal logging level (inclusive)

```
//sets minimum log level to WARN, lower levels (DEBUG, INFO) are not written to log
$logger->setLevel(LogLevel::WARN);
```

### setMaxLevel

[](#setmaxlevel)

Sets maximal logging level (inclusive)

```
//sets maximum log level to WARN, higher levels (ERROR, FATAL) are not written to log
$logger->setMaxLevel(LogLevel::WARN);
```

### setDateFormat

[](#setdateformat)

Sets date format for log lines.
Expected format string is the same as for use with DateTime.format() method.
Default Logger class format: 'Y-m-d\\TH:i:s.uP'.

```
	$logger->setDateFormat('Y-m-d H:i:s');
```

### log

[](#log)

Log method writes line to log.

```
$logger->log(LogLevel::INFO,'main process','example log message');
```

Log output format:

```
2025-12-09T14:41:52.362406+01:00: [info] (main process): example log message

```

LogLevel
--------

[](#loglevel)

LogLevel enum class defines logging levels.

Levels / log file representation

- DEBUG / \[debug\]
- INFO / \[info\]
- WARN / \[warning\]
- ERROR / \[error\]
- FATAL / \[fatal\]

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance72

Regular maintenance activity

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity24

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

159d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/fc9a4843bfd807b6a86c2518447cfceb6d3d883dd68424cc66aec8552d4a52fa?d=identicon)[derywat](/maintainers/derywat)

---

Top Contributors

[![derywat](https://avatars.githubusercontent.com/u/46571114?v=4)](https://github.com/derywat "derywat (1 commits)")

### Embed Badge

![Health badge](/badges/derywat-php-logging/health.svg)

```
[![Health](https://phpackages.com/badges/derywat-php-logging/health.svg)](https://phpackages.com/packages/derywat-php-logging)
```

###  Alternatives

[psr/log

Common interface for logging libraries

10.4k1.2B9.2k](/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.2M138](/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)[ekino/newrelic-bundle

Integrate New Relic into Symfony2

28111.2M8](/packages/ekino-newrelic-bundle)

PHPackages © 2026

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