{"id":1305,"date":"2023-11-29T06:37:48","date_gmt":"2023-11-29T06:37:48","guid":{"rendered":"https:\/\/www.devopssupport.in\/blog\/?p=1305"},"modified":"2023-11-29T06:37:50","modified_gmt":"2023-11-29T06:37:50","slug":"troubleshooting-laravel-laravel-emergency-unable-to-create-configured-logger-using-emergency-logger","status":"publish","type":"post","link":"https:\/\/www.devopssupport.in\/blog\/troubleshooting-laravel-laravel-emergency-unable-to-create-configured-logger-using-emergency-logger\/","title":{"rendered":"Troubleshooting Laravel: &#8220;laravel.EMERGENCY: Unable to create configured logger. Using emergency logger.&#8221;"},"content":{"rendered":"\n<p>If you&#8217;ve recently upgraded your Laravel application from version 5.7 to 10 and encountered the error &#8220;laravel.EMERGENCY: Unable to create configured logger. Using emergency logger,&#8221; don&#8217;t worry; you&#8217;re not alone. The issue and provide you with a step-by-step solution to get your Laravel application back on track. <\/p>\n\n\n\n<p>The error suggests that Laravel is unable to create a configured logger, resulting in the use of the emergency logger. This typically indicates a misconfiguration or missing file in your logging setup.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Solution: Adding the Logging Configuration<\/h2>\n\n\n\n<p>In Laravel 5.7, the default logging configuration might have been handled differently compared to Laravel 10. The absence of a <code>config\/logging.php<\/code> file in your Laravel 10 application could lead to this error.<\/p>\n\n\n\n<p>To resolve this issue, you need to create the <code><strong>config\/logging.php<\/strong><\/code> file. Here&#8217;s a sample configuration that you can use: <\/p>\n\n\n\n<p><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\r\n\r\nuse Monolog\\Handler\\NullHandler;\r\nuse Monolog\\Handler\\StreamHandler;\r\nuse Monolog\\Handler\\SyslogUdpHandler;\r\nuse Monolog\\Processor\\PsrLogMessageProcessor;\r\n\r\nreturn &#91;\r\n\r\n    \/*\r\n    |--------------------------------------------------------------------------\r\n    | Default Log Channel\r\n    |--------------------------------------------------------------------------\r\n    |\r\n    | This option defines the default log channel that gets used when writing\r\n    | messages to the logs. The name specified in this option should match\r\n    | one of the channels defined in the \"channels\" configuration array.\r\n    |\r\n    *\/\r\n\r\n    'default' => env('LOG_CHANNEL', 'stack'),\r\n\r\n    \/*\r\n    |--------------------------------------------------------------------------\r\n    | Deprecations Log Channel\r\n    |--------------------------------------------------------------------------\r\n    |\r\n    | This option controls the log channel that should be used to log warnings\r\n    | regarding deprecated PHP and library features. This allows you to get\r\n    | your application ready for upcoming major versions of dependencies.\r\n    |\r\n    *\/\r\n\r\n    'deprecations' => &#91;\r\n        'channel' => env('LOG_DEPRECATIONS_CHANNEL', 'null'),\r\n        'trace' => false,\r\n    ],\r\n\r\n    \/*\r\n    |--------------------------------------------------------------------------\r\n    | Log Channels\r\n    |--------------------------------------------------------------------------\r\n    |\r\n    | Here you may configure the log channels for your application. Out of\r\n    | the box, Laravel uses the Monolog PHP logging library. This gives\r\n    | you a variety of powerful log handlers \/ formatters to utilize.\r\n    |\r\n    | Available Drivers: \"single\", \"daily\", \"slack\", \"syslog\",\r\n    |                    \"errorlog\", \"monolog\",\r\n    |                    \"custom\", \"stack\"\r\n    |\r\n    *\/\r\n\r\n    'channels' => &#91;\r\n        'stack' => &#91;\r\n            'driver' => 'stack',\r\n            'channels' => &#91;'single'],\r\n            'ignore_exceptions' => false,\r\n        ],\r\n\r\n        'single' => &#91;\r\n            'driver' => 'single',\r\n            'path' => storage_path('logs\/laravel.log'),\r\n            'level' => env('LOG_LEVEL', 'debug'),\r\n            'replace_placeholders' => true,\r\n        ],\r\n\r\n        'daily' => &#91;\r\n            'driver' => 'daily',\r\n            'path' => storage_path('logs\/laravel.log'),\r\n            'level' => env('LOG_LEVEL', 'debug'),\r\n            'days' => 14,\r\n            'replace_placeholders' => true,\r\n        ],\r\n\r\n        'slack' => &#91;\r\n            'driver' => 'slack',\r\n            'url' => env('LOG_SLACK_WEBHOOK_URL'),\r\n            'username' => 'Laravel Log',\r\n            'emoji' => ':boom:',\r\n            'level' => env('LOG_LEVEL', 'critical'),\r\n            'replace_placeholders' => true,\r\n        ],\r\n\r\n        'papertrail' => &#91;\r\n            'driver' => 'monolog',\r\n            'level' => env('LOG_LEVEL', 'debug'),\r\n            'handler' => env('LOG_PAPERTRAIL_HANDLER', SyslogUdpHandler::class),\r\n            'handler_with' => &#91;\r\n                'host' => env('PAPERTRAIL_URL'),\r\n                'port' => env('PAPERTRAIL_PORT'),\r\n                'connectionString' => 'tls:\/\/'.env('PAPERTRAIL_URL').':'.env('PAPERTRAIL_PORT'),\r\n            ],\r\n            'processors' => &#91;PsrLogMessageProcessor::class],\r\n        ],\r\n\r\n        'stderr' => &#91;\r\n            'driver' => 'monolog',\r\n            'level' => env('LOG_LEVEL', 'debug'),\r\n            'handler' => StreamHandler::class,\r\n            'formatter' => env('LOG_STDERR_FORMATTER'),\r\n            'with' => &#91;\r\n                'stream' => 'php:\/\/stderr',\r\n            ],\r\n            'processors' => &#91;PsrLogMessageProcessor::class],\r\n        ],\r\n\r\n        'syslog' => &#91;\r\n            'driver' => 'syslog',\r\n            'level' => env('LOG_LEVEL', 'debug'),\r\n            'facility' => LOG_USER,\r\n            'replace_placeholders' => true,\r\n        ],\r\n\r\n        'errorlog' => &#91;\r\n            'driver' => 'errorlog',\r\n            'level' => env('LOG_LEVEL', 'debug'),\r\n            'replace_placeholders' => true,\r\n        ],\r\n\r\n        'null' => &#91;\r\n            'driver' => 'monolog',\r\n            'handler' => NullHandler::class,\r\n        ],\r\n\r\n        'emergency' => &#91;\r\n            'path' => storage_path('logs\/laravel.log'),\r\n        ],\r\n    ],\r\n\r\n];<\/code><\/pre>\n\n\n\n<p>Copy the above configuration into a new <code>config\/logging.php<\/code> file in your Laravel 10 application. Ensure that you customize it based on your specific needs.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Running Your Application<\/h2>\n\n\n\n<p>After adding the logging configuration, try running your Laravel application again. The error should be resolved, and you should see your log files being generated in the specified <code>storage\/logs<\/code> directory.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you&#8217;ve recently upgraded your Laravel application from version 5.7 to 10 and encountered the error &#8220;laravel.EMERGENCY: Unable to create configured logger. Using emergency logger,&#8221; don&#8217;t worry;&#8230; <\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[549,551,547,550,548],"class_list":["post-1305","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-laravel-emergency","tag-troubleshooting-laravel","tag-troubleshooting-laravel-laravel-emergency-unable-to-create-configured-logger-using-emergency-logger","tag-unable-to-create-configured-logger","tag-using-emergency-logger"],"_links":{"self":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts\/1305","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/comments?post=1305"}],"version-history":[{"count":2,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts\/1305\/revisions"}],"predecessor-version":[{"id":1373,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts\/1305\/revisions\/1373"}],"wp:attachment":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/media?parent=1305"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/categories?post=1305"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/tags?post=1305"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}