PHPackages                             cristimark/logger-mezzio-module - 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. cristimark/logger-mezzio-module

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

cristimark/logger-mezzio-module
===============================

A Logger for your Mezzio application to trap php errors &amp; exceptions

11PHP

Since Dec 10Pushed 5y ago1 watchersCompare

[ Source](https://github.com/MarkVyrus/LoggerMezzioModule)[ Packagist](https://packagist.org/packages/cristimark/logger-mezzio-module)[ RSS](/packages/cristimark-logger-mezzio-module/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

LoggerMezzioModule
------------------

[](#loggermezziomodule)

> This is README for version ^3.0 which only support Mezzio version 3 with php ^7.1. Introduction

---

LoggerMezzioModule is a module for Error Logging (DB and .txt file). Mezzio 3 for Exceptions in 'dispatch.error' or 'render.error' or during request and response, and [PHP E\_\* Error](http://www.php.net/manual/en/errorfunc.constants.php).

Features
--------

[](#features)

- Save to DB with Db Writer Adapter.
- Log Exception (dispatch.error and render.error) and PHP Errors in all events process.
- Support excludes [PHP E\_\* Error](http://www.php.net/manual/en/errorfunc.constants.php) (eg: exclude E\_USER\_DEPRECATED or specific E\_USER\_DEPRECATED with specific message) in config settings.
- Support excludes [PHP Exception](http://php.net/manual/en/spl.exceptions.php) (eg: Exception class or classes that extends it or specific exception class with specific message) in config settings.
- Handle only once log error for same error per configured time range.
- Set default page (web access) or default message (console access) for error if configured 'display\_errors' = 0.
- Set default content when request is XMLHttpRequest via 'ajax' configuration.
- Set default content when there is [no template service](https://github.com/mezzio/mezzio-template/blob/9b6c2e06f8c1d7e43750f72b64cc749552f2bdbe/src/TemplateRendererInterface.php) via 'no\_template' configuration (Mezzio 3).
- Provide request information ( http method, raw data, body data, query data, files data, cookie data, and ip address).
- Send to a .txt log\_error file is DB is not available

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

[](#installation)

**1. Import the following SQL for Mysql**

```
DROP TABLE IF EXISTS `log_error`;

CREATE TABLE `log_error` (
  `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `type` int(11) NOT NULL,
  `event` text NOT NULL,
  `url` varchar(2000) NOT NULL,
  `file` varchar(2000) NOT NULL,
  `line` int(11) NOT NULL,
  `error_type` varchar(255) NOT NULL,
  `trace` text NULL,
  `request_data` text NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
```

> If you use other RDBMS, you may follow the `log` table structure above.

**2. Setup your Laminas\\Db\\Adapter\\AdapterInterface service or your Doctrine\\ORM\\EntityManager service config**

You can use 'db' (with *Laminas\\Db*) config or 'doctrine' (with *DoctrineORMModule*) config that will be transformed to be usable with `Laminas\Log\Writer\Db`.

```
