# Silalahi logger implementation

**URL:** <https://discourse.slimframework.com/t/silalahi-logger-implementation/1025>\
**Category:** Questions\
**Created:** [December 22, 2016, 12:36pm UTC](https://discourse.slimframework.com/t/silalahi-logger-implementation/1025 "2016-12-22T12:36:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anupam\_4881](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@anupam\_4881](https://discourse.slimframework.com/u/anupam_4881)\
**Post date:** [December 22, 2016, 12:36pm UTC](https://discourse.slimframework.com/t/silalahi-logger-implementation/1025/1 "2016-12-22T12:36:54Z")

</div>

Hi ,

I am trying to implement one logger which i can use in any function to write custom log. Silalahi is working good , but when i try to implement same in below way it is not working, any help will be appreciated.  
Seems logger is not getting how to call this.

sample code.

\<?php require "vendor/autoload.php"; $app = new \Slim\App(); use Monolog\Logger; $container = new \Slim\Container(); $app = new \Slim\App($container); $app-\>add(new Silalahi\Slim\Logger( ['path' =\> '/var/log/', 'name' =\> 'main\_logger\_', 'name\_format' =\> 'Y-m-d', 'extension' =\> 'log', 'message\_format' =\> '[%label%] %date% %message%' ] ) ); $app-\>group('/login', function() { $this-\>put('/wines/{id}', 'updateWine',function ($request,$response,$args) {}); } ); function updateWine($request, $response, $args) { // Info level log $this-\>logger-\>write("This message from logger class library", Silalahi\Slim\Logger::INFO); $id=$args['id']; $value = json\_decode($request-\>getBody()); } $app-\>run(); ?\>

---

<div class="post-metadata">

**Author:** ![shavonn](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/shavonn/32/299_2.png) [@shavonn](https://discourse.slimframework.com/u/shavonn)\
**Post date:** [December 27, 2016, 4:56am UTC](https://discourse.slimframework.com/t/silalahi-logger-implementation/1025/2 "2016-12-27T04:56:39Z")

</div>

You’ve not defined it anywhere as ‘logger’. You’ve added it to the app, not the container which I think is usually the idea.

```
$container['logger'] = function($container) {
	return new Silalahi\Slim\Logger([
		'path' => '/var/log/',
		'name' => 'main_logger_',
		'name_format' => 'Y-m-d',
		'extension' => 'log',
		'message_format' => '[%label%] %date% %message%'
	]);
};

```

and then when you use it:

`$this->container->logger->write("This message from logger class library", Silalahi\Slim\Logger::INFO);`
