SS config logging not working in ss4

Hi everyone,
I’m a new bie and need you help.
I was learning SS in a few days and got problem with this lesson: https://www.silverstripe.org/learn/lessons/v4/advanced-environment-configuration-1
I just added a new logging.yml into folder app with this content:

---
Name: example-all-logging
---
SilverStripe\Core\Injector\Injector:
  Psr\Log\LoggerInterface:
    calls:
      FileLogger: [ pushHandler, [ %$FileLogger ] ]
  FileLogger:
    class: Monolog\Handler\StreamHandler
    constructor:
      - "../errors.log"
      - "notice"

This is my project structure:

But I got after run my local url: http://example.ss.local:8089/?flush
is

If anyone have any ideas to fix it, please help to share. Thank you so much!

The most likely problem if specifically adding that configuration caused the 500 error (i.e. if removing that configuration lets you access the site again) is file permissions. Make sure the errors.log file exists and that the user running php (probably www-data if you’re using apache) has write permissions for the file.

You might also have syntax errors in your yaml - for example %$FileLogger should have quotes around it (should be '%$FileLogger').

You should also enable logging on a webserver level (e.g. if you’re using apache, configure error logs in your virtualhost). That way for 500 errors you’ll be able to see in those logs what went wrong, even if your silverstripe logging isn’t working yet.

1 Like

Thank you mate!
The problem is syntax errors.

I updated yml file and it works

1 Like