# Errorhandler with logger, should be in skeleton?

**URL:** <https://discourse.laminas.dev/t/errorhandler-with-logger-should-be-in-skeleton/138>\
**Category:** Mezzio\
**Created:** [June 1, 2017, 3:40pm UTC](https://discourse.laminas.dev/t/errorhandler-with-logger-should-be-in-skeleton/138 "2017-06-01T15:40:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![belgattitude](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/belgattitude/32/241_2.png) [@belgattitude](https://discourse.laminas.dev/u/belgattitude)\
**Post date:** [June 1, 2017, 3:40pm UTC](https://discourse.laminas.dev/t/errorhandler-with-logger-should-be-in-skeleton/138/1 "2017-06-01T15:40:22Z")

</div>

Some thoughts about error logging in expressive.

Looking at the [docs for error handling](https://docs.zendframework.com/zend-expressive/features/error-handling/) and the section ‘Listening for errors’. I noticed two small things:

1. Promoting the use of [delegators](https://docs.zendframework.com/zend-expressive/features/container/delegator-factories/) is fine, but restricts usage to zend-service-manager. At least an option should be nice.
2. Was a bit confused about where to register the `LoggingErrorListenerDelegatorFactory`… put it dependencies.php under ‘delegators’, but was not super intuitive (at least for me):

```php
return [
    'dependencies' => [
        'factories' => [
            // ...
            Psr\Log\LoggerInterface::class => App\Infrastructure\Log\LoggerFactory::class,
        ],
        'delegators' => [
            Zend\Stratigility\Middleware\ErrorHandler::class => [
                App\Infrastructure\Log\LoggingErrorListenerDelegatorFactory::class,
            ]
        ]
    ],
];

```

So everything is fine… but I found it a bit sad to have to spend an hour to just enable basic logging.

I think it could be good to have it in skeleton by default (with a NullLogger for example) and I would be happy to contribute a P/R, but would like to have some feedback first especially

- How to _emulate_ the delegators with Pimple, Aura.DI ?
- What would be the ideal namespace (App\Infrastructure\Log) to choose to set the loggers ?

Any thoughts on this ? Or is there’s already something that could be easily provide _global_ error logging ?

---

<div class="post-metadata">

**Author:** ![belgattitude](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/belgattitude/32/241_2.png) [@belgattitude](https://discourse.laminas.dev/u/belgattitude)\
**Post date:** [June 1, 2017, 3:53pm UTC](https://discourse.laminas.dev/t/errorhandler-with-logger-should-be-in-skeleton/138/2 "2017-06-01T15:53:35Z")

</div>

Opened an issue for the skeleton: [https://github.com/zendframework/zend-expressive-skeleton/issues/158](https://github.com/zendframework/zend-expressive-skeleton/issues/158) just for open discussion.

---

<div class="post-metadata">

**Author:** ![matthew](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/matthew/32/14_2.png) [@matthew](https://discourse.laminas.dev/u/matthew)\
**Post date:** [June 1, 2017, 4:13pm UTC](https://discourse.laminas.dev/t/errorhandler-with-logger-should-be-in-skeleton/138/3 "2017-06-01T16:13:55Z")

</div>

> [@belgattitude](#):
>
> Promoting the use of delegators is fine, but restricts usage to zend-service-manager.

No, it doesn’t. As of v2.0 of the skeleton, we support delegator factories in all DI containers we currently support (we even [document how to write them to work across container implementations](https://docs.zendframework.com/zend-expressive/features/container/delegator-factories/)).

---

<div class="post-metadata">

**Author:** ![matthew](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/matthew/32/14_2.png) [@matthew](https://discourse.laminas.dev/u/matthew)\
**Post date:** [June 1, 2017, 4:27pm UTC](https://discourse.laminas.dev/t/errorhandler-with-logger-should-be-in-skeleton/138/4 "2017-06-01T16:27:12Z")

</div>

I’ve provided feedback via your github issue: [https://github.com/zendframework/zend-expressive-skeleton/issues/158#issuecomment-305547082](https://github.com/zendframework/zend-expressive-skeleton/issues/158#issuecomment-305547082)
