# Logger works but exceptions are not being logged to file, only "screen"

**URL:** <https://discourse.slimframework.com/t/logger-works-but-exceptions-are-not-being-logged-to-file-only-screen/1406>\
**Category:** Questions\
**Created:** [April 18, 2017, 8:41am UTC](https://discourse.slimframework.com/t/logger-works-but-exceptions-are-not-being-logged-to-file-only-screen/1406 "2017-04-18T08:41:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![GGGforce](https://avatars.discourse-cdn.com/v4/letter/g/ea666f/32.png) [@GGGforce](https://discourse.slimframework.com/u/GGGforce)\
**Post date:** [April 18, 2017, 8:41am UTC](https://discourse.slimframework.com/t/logger-works-but-exceptions-are-not-being-logged-to-file-only-screen/1406/1 "2017-04-18T08:41:11Z")

</div>

I’m using what I believe are the default Monolog settings. Exceptions are being logged to the web page but not the log file. However if I explicitly generate a log entry, the file is updated, so I know the logger works. I’d like exceptions to be logged to a file so that I can debug them. Can somebody please help accomplish this?

**settings.php**  
return [  
‘settings’ =\> [  
‘displayErrorDetails’ =\> true, // set to false in production  
’addContentLengthHeader’ =\> false, // Allow the web server to send the content-length header

// Renderer settings  
’renderer’ =\> [  
‘template\_path’ =\> **DIR**. ‘/…/templates/’,  
],

// Monolog settings  
’logger’ =\> [  
‘name’ =\> ‘slim-app’,  
‘path’ =\> **DIR**. ‘/…/logs/app.log’,  
‘level’ =\> \Monolog\Logger::DEBUG,  
],  
],  
];

**dependencies.php**  
$container = $app-\>getContainer();

// view renderer  
$container[‘renderer’] = function ($c) {  
$settings = $c-\>get(‘settings’)[‘renderer’];  
return new Slim\Views\PhpRenderer($settings[‘template\_path’]);  
};

// monolog  
$container[‘logger’] = function ($c) {  
$settings = $c-\>get(‘settings’)[‘logger’];  
$logger = new Monolog\Logger($settings[‘name’]);  
$logger-\>pushProcessor(new Monolog\Processor\UidProcessor());  
$logger-\>pushHandler(new Monolog\Handler\StreamHandler($settings[‘path’], $settings[‘level’]));  
return $logger;  
};

---

<div class="post-metadata">

**Author:** ![akrabat](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/akrabat/32/9_2.png) [@akrabat](https://discourse.slimframework.com/u/akrabat)\
**Post date:** [April 18, 2017, 9:57am UTC](https://discourse.slimframework.com/t/logger-works-but-exceptions-are-not-being-logged-to-file-only-screen/1406/2 "2017-04-18T09:57:10Z")

</div>

You need to write your own error handler as Slim core doesn’t know about your monolog instance.

See [https://akrabat.com/logging-errors-in-slim-3/](https://akrabat.com/logging-errors-in-slim-3/) for ideas.
