PHPackages                             davidhavl/dherrorlogging - 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. davidhavl/dherrorlogging

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

davidhavl/dherrorlogging
========================

Full featured error logging module for ZF2/ZF3 application

2.2.2(8y ago)1924.5k12[2 issues](https://github.com/DavidHavl/DhErrorLogging/issues)[1 PRs](https://github.com/DavidHavl/DhErrorLogging/pulls)MITPHPPHP ^5.6 || ^7.0

Since Aug 4Pushed 5y ago6 watchersCompare

[ Source](https://github.com/DavidHavl/DhErrorLogging)[ Packagist](https://packagist.org/packages/davidhavl/dherrorlogging)[ Docs](https://github.com/DavidHavl/DhErrorLogging)[ RSS](/packages/davidhavl-dherrorlogging/feed)WikiDiscussions master Synced today

READMEChangelog (8)Dependencies (12)Versions (9)Used By (0)

DHErrorLogging - ZF2 / ZF3 application error logging
====================================================

[](#dherrorlogging---zf2--zf3-application-error-logging)

[![Latest Version](https://camo.githubusercontent.com/d33f8a69ce03ba44eb93508a2e6cdd01742e1e9646ec9d5e420296feca988d4e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f44617669644861766c2f44684572726f724c6f6767696e672e7376673f7374796c653d666c61742d737175617265)](https://github.com/DavidHavl/DhErrorLogging/releases)[![Downloads](https://camo.githubusercontent.com/102be85f76832c5e99cfde2db34aebeb6261b4e622b889f17c656dc587ae12b3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f64617669646861766c2f64686572726f726c6f6767696e672e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/davidhavl/dherrorlogging)

Introduction
------------

[](#introduction)

**Full featured Error logging module for ZF2/ZF3 MVC application.**

Features
--------

[](#features)

- Log framework specific exceptions (in dispatch or render lifecycle)
- Log other exception
- Log php errors
- Log fatal errors or parse errors (outside of dispatch or render lifecycle)
- Ability to filter which [PHP E\_\* Error](http://www.php.net/manual/en/errorfunc.constants.php) to log or not (i.e.: don't log E\_USER\_DEPRECATED errors) via config setting
- The module adds several useful info to the final log such as IP, request, url called, session id, backtrace,...
- Ability to choose multiple destinations where to log to, via log writers (DB, email, file, chromephp, 'fingerscrossed', 'firephp', 'mail', 'mock', 'null', 'syslog', 'zendmonitor')
- Custom DB log writer included aside of the other default log writers provided by ZF
- Custom Doctrine log writer included
- Content negotiation included (i.e.: renders JSON response for json request, console response for console request, html response for rest of the requests..)
- Ability to show a pretty error page that includes an error code (which helps to identify the problem when reporting it back to you) to users
- Pretty error page templates for each of the error/exception types (dispatch, render, exception, error, fatal, console., json)

Installation
------------

[](#installation)

- Add `"davidhavl/dherrorlogging": "^2.0"` to the require section of your composer.json
- Add `'DhErrorLogging'` to the modules array in your application.config.php (or modules.config.php in ZF3 skeleton application) before any other custom modules (or as close to the top as possible).
- If you have a ./config/autoload/ directory set up for your project, you can drop the `dherrorlogging.global.php.dist` (rename it to `dherrorlogging.global.php`) config file from config directory in it and change the values as you wish.
- Enable at least one log writer (in the `dherrorlogging.global.php` "log\_writers" section).
- To display an Error Reference in your own exception template (error/404, error/index) make sure you echo the error reference variable errorReference; ?&gt;

Notes
-----

[](#notes)

Via the `dherrorlogging.global.php` you can enable/disable the logging functionality completely or disable just some types of errors/exceptions. You can configure several other things such as template path for errors or log writers. You can also overwrite the logger, processor, reference generator or response sender if you wish (and know what you are doing).

When adding new log writer you can either add new config array for some of the the standard ZF2 writers that don't need injection of other objects (stream, chromephp, 'fingerscrossed', 'firephp', 'mail', 'mock', 'null', 'syslog', 'zendmonitor') or identifier of your own registered log writer factory (registered in main config section \['log\_writers'\]) to the '\['dherrorlogging'\]\['log\_writers'\]' section.

In order for the error page to return http status code 500 you should have PHP display\_errors off.

### Example db writer setup:

[](#example-db-writer-setup)

Let say you want to enable logging to database via zend db. I have provided a custom db log writer (`DhErrorLogging\DbWriter`) right out of the box, so all you need to do is to uncomment the db part (line 71 - 91) of the new dherrorlogging.global.php in your config directory so that the module knows you want to use database, and lastly say you are using MySQL you can use the bellow sql schema (also found in /data/sql directory) to create log table in your database:

```
CREATE TABLE IF NOT EXISTS `error_log` (
  `log_id` int(11) NOT NULL AUTO_INCREMENT,
  `creation_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `reference` varchar(6) DEFAULT '',
  `type` varchar(10) DEFAULT 'ERROR',
  `priority` varchar(6) DEFAULT 'DEBUG',
  `message` text,
  `file` text,
  `line` varchar(12),
  `trace` text,
  `xdebug` text,
  `uri` text,
  `request` text,
  `ip` varchar(45) DEFAULT NULL,
  `session_id` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`log_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
```

Or use your own table and field names but make sure you adjust the `['db']['options']['table_name']` and `['db']['options']['table_map']` accordingly. Also make sure that zend db adapter alias (line 191 of dherrorlogging.global.php) is set to same adapter you are using.

### Example doctrine writer setup:

[](#example-doctrine-writer-setup)

I have provided a custom doctrine log writer (`DhErrorLogging\Writer\DoctrineWriter`) right out of the box, so all you need to do is to uncomment the doctrine part (line 100 - 102) of the new dherrorlogging.global.php and run doctrine update command to create the new table. Make sure that doctrine entity manager alias (line 199 of dherrorlogging.global.php) is set to same one you are using.

Migration from v1 to v2
-----------------------

[](#migration-from-v1-to-v2)

Version 2 is in large respect a complete rewrite. The following has also been added:

- error type enable/disable,
- exception filter,
- module options,
- response sender (ability to send different response depending on where it come from or what request accept headers are)

In matter of settings, the following has been deprecated: \['dherrorlogging'\]\['priority'\] You can easily re-enable this functionality if you use your own logger implementation.

Contributing
------------

[](#contributing)

Want to make it better or more polished? Feel free to send pull request. I am always happy to collaborate with others or listen to a feedback. Don't know where to start? How about help with writing tests.

TODO:
-----

[](#todo)

- Tests. Yes it is boring to code, but necessary.

###  Health Score

36

—

LowBetter than 83% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 92.1% 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 ~180 days

Recently: every ~197 days

Total

8

Last Release

2985d ago

Major Versions

v0.7 → v1.02014-10-31

v1.0 → v2.0-alpha.12015-03-24

### Community

Maintainers

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

---

Top Contributors

[![DavidHavl](https://avatars.githubusercontent.com/u/2153848?v=4)](https://github.com/DavidHavl "DavidHavl (70 commits)")[![jwasilewski-bit](https://avatars.githubusercontent.com/u/224731308?v=4)](https://github.com/jwasilewski-bit "jwasilewski-bit (5 commits)")[![Gounlaf](https://avatars.githubusercontent.com/u/236413?v=4)](https://github.com/Gounlaf "Gounlaf (1 commits)")

---

Tags

exceptionerrorloggerzf2zend framework 2Zend Frameworkzf3php errorerror\_logZend Framework 3

### Embed Badge

![Health badge](/badges/davidhavl-dherrorlogging/health.svg)

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

###  Alternatives

[snapshotpl/zf-snap-php-debug-bar

PHP Debug Bar module for Zend Framework 2

3026.1k](/packages/snapshotpl-zf-snap-php-debug-bar)[facile-it/sentry-module

This module allows integration of Sentry Client into laminas and mezzio

21363.5k](/packages/facile-it-sentry-module)[justbetter/magento2-sentry

Magento 2 Logger for Sentry

1821.4M3](/packages/justbetter-magento2-sentry)

PHPackages © 2026

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