PHPackages                             xp-framework/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. xp-framework/logging

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

xp-framework/logging
====================

Logging for the XP Framework

v11.3.0(4mo ago)0320.0k↓18.6%2[1 issues](https://github.com/xp-framework/logging/issues)15BSD-3-ClausePHPPHP &gt;=7.0.0CI passing

Since Aug 22Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/xp-framework/logging)[ Packagist](https://packagist.org/packages/xp-framework/logging)[ Docs](http://xp-framework.net/)[ RSS](/packages/xp-framework-logging/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (4)Versions (26)Used By (15)

Logging
=======

[](#logging)

[![Build status on GitHub](https://github.com/xp-framework/logging/workflows/Tests/badge.svg)](https://github.com/xp-framework/logging/actions)[![XP Framework Module](https://raw.githubusercontent.com/xp-framework/web/master/static/xp-framework-badge.png)](https://github.com/xp-framework/core)[![BSD Licence](https://raw.githubusercontent.com/xp-framework/web/master/static/licence-bsd.png)](https://github.com/xp-framework/core/blob/master/LICENCE.md)[![Requires PHP 7.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-7_0plus.svg)](http://php.net/)[![Supports PHP 8.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-8_0plus.svg)](http://php.net/)[![Latest Stable Version](https://camo.githubusercontent.com/f815df277dbeb2b164ea89c234d2ac965f7b3544cd32dd70009bc8198b91bdbd/68747470733a2f2f706f7365722e707567782e6f72672f78702d6672616d65776f726b2f6c6f6767696e672f76657273696f6e2e737667)](https://packagist.org/packages/xp-framework/logging)

Logging for the XP Framework.

Example
-------

[](#example)

```
use util\log\Logging;
use lang\Throwable;
use peer\ConnectException;

$logger= Logging::named('service')->toConsole();
$logger->info('Starting application');

try {
  $service->operation();
} catch (ConnectException $e) {
  $logger->warn('Service not available', $e);
} catch (Throwable $t) {
  $logger->error('Error during service invocation', $t);
}
```

Levels
------

[](#levels)

This library supports the following levels: DEBUG, INFO, WARN and ERROR. As seen above, messages can be logged using methods named after these levels. All methods have a *printf*-style variant:

- `debug(var... $args)` and `debugf(string $format, var... $args)`.
- `info(var... $args)` and `infof(string $format, var... $args)`.
- `warn(var... $args)` and `warnf(string $format, var... $args)`.
- `error(var... $args)` and `errorf(string $format, var... $args)`.

Appenders
---------

[](#appenders)

The following appenders are available:

- `util.log.FileAppender(string $filename)` - Logs to a local file
- `util.log.ConsoleAppender()` - Logs to console
- `util.log.ColoredConsoleAppender()` - Logs to console using colors depending on log level
- `util.log.SmtpAppender(string $email, string $prefix= "", bool $sync= true)` - Logs by email to a given email address
- `util.log.StreamAppender(io.streams.OutputStream $out)` - Logs to any output stream from `io.streams`.
- `util.log.SyslogAppender(string $identifier, int $facility= LOG_USER)` - Logs using syslog facility
- `util.log.SyslogUdpAppender(string $ip= '127.0.0.1', int $port= 514, string $identifier= null, int $facility= LOG_USER, string $hostname= null)` - Logs using syslog protocol over UDP
- `util.log.BufferedAppender()` - Logs to a memory buffer

Layout
------

[](#layout)

The default log layout includes time, pid, level and message implemented by the `util.log.layout.DefaultLayout` class. It renders as follows:

```
[13:43:39  4368  info] Starting application

```

The log layout can be changed by instantiating the `util.log.layout.PatternLayout`, passing a format string and using the appenders `setLayout()` method to use it. The format string consists of format tokens preceded by a percent sign (%) and any other character. The following format tokens are supported:

- `%m` - Message
- `%c` - Category name
- `%l` - Log level - lowercase
- `%L` - Log level - uppercase
- `%d` - Date in YYYY-MM-DD
- `%t` - Time in HH:MM:SS
- `%p` - Process ID
- `%%` - A literal percent sign (%)
- `%n` - A line break
- `%x` - Context information, if available

Configuration
-------------

[](#configuration)

Instead of using the [Logging DSL](https://github.com/xp-framework/logging/pull/6) to create your log setup programmatically, you can use the [configuration API](https://github.com/xp-framework/logging/pull/12), which works with INI files:

```
[default]
uses=console|syslog|files

[console]
class=util.log.ConsoleAppender
level=ALL

[files]
class=util.log.FileAppender
args="/var/log/server.log"
level=ALL

[syslog]
class=util.log.SyslogUdpAppender
args=127.0.0.1|514|server
level=WARN|ERROR
```

Further reading
---------------

[](#further-reading)

- [Log Contexts](https://github.com/xp-framework/xp-framework/pull/239)
- [Support for rolling file names](https://github.com/xp-framework/xp-framework/pull/353)

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance76

Regular maintenance activity

Popularity33

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 98.7% 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 ~164 days

Recently: every ~524 days

Total

24

Last Release

132d ago

Major Versions

v7.1.0 → v8.0.02017-05-29

v8.3.0 → v9.0.02018-08-24

v6.7.0 → v9.1.12018-11-05

v9.1.4 → v10.0.02020-04-10

v10.0.0 → v11.0.02021-10-21

PHP version history (4 changes)v6.4.2PHP &gt;=5.4.0

v6.5.0PHP &gt;=5.5.0

v8.0.0PHP &gt;=5.6.0

v10.0.0PHP &gt;=7.0.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/07d18d882c8b4aaf3466432f64018214f2771eda333202175431ee7233795376?d=identicon)[thekid](/maintainers/thekid)

---

Top Contributors

[![thekid](https://avatars.githubusercontent.com/u/696742?v=4)](https://github.com/thekid "thekid (155 commits)")[![johannes85](https://avatars.githubusercontent.com/u/470531?v=4)](https://github.com/johannes85 "johannes85 (2 commits)")

---

Tags

iniloggingphpsyslogxp-frameworkmodulexp

### Embed Badge

![Health badge](/badges/xp-framework-logging/health.svg)

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

###  Alternatives

[xp-framework/compiler

XP Compiler

2026.0k9](/packages/xp-framework-compiler)

PHPackages © 2026

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