Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misfunction with the default prod settings and when using custom query to login #463

Open
omgslinux opened this issue Sep 7, 2023 · 1 comment

Comments

@omgslinux
Copy link

The default prod settings since about symfony 5 in monolog.yaml are these:

when@prod:
    monolog:
        handlers:
            main:
                type: fingers_crossed
                action_level: error
                handler: nested
                excluded_http_codes: [404, 405]
                buffer_size: 50 # How many messages should be saved? Prevent memory leaks
            nested:
                type: stream
                path: php://stderr
                level: debug
                formatter: monolog.formatter.json
            console:
                type: console
                process_psr_3_messages: false
                channels: ["!event", "!doctrine"]
            deprecation:
                type: stream
                channels: [deprecation]
                path: php://stderr

Unlike the dev settings, which work like a charm, but about causing problems, one basically could think that the only possible problem of these settings is "lack of proper log".
However, I've been working in an app for several years, since symfony 3 (where it worked ok), but when trying to upgrade to symfony 5 (and later, 6.x), it had a weird misfunctionality when a user tried to login in the app. The only difference I could find with other apps new or upgraded that work without problem (except the above mention to "lack of proper log") is that this uses a custom query for login, instead of the default method. Only in some specific circumstances in prod the login worked as expected, while in the rest, it didn't like in dev, without any kind of logging that could help to debug the issue.
Since this "lack of proper log" didn't prevent any other apps to work, I didn't think to cause any misfunction in the app itself. Then I decided to have some log in order to debug the problem by cloning the dev settings in the "main" section of monolog settings for prod, and since by doing nothing else I started to have proper log, I didn't do anything else. The misfunction was still happenning. Only when I decided to clean the prod cache (since I think shouldn't be necessary since there were no changes in the code), I found out that the app worked as expected, and the misfunction went away. I've been able to reproduce this behaviour in the three servers where I've tried to test the upgraded app.
At this moment, I don't know why this happens, and this is the reason why I write this issue, in order to prevent others to find the same problem. There might be an issue somewhere else that leads to this, or it's just that "the new default prod settings are buggy and should be changed".

If you want more details, I started a thread in stackoverflow

Thanks in advance.

@stof
Copy link
Member

stof commented Nov 6, 2023

I don't understand the relation between using a custom query to login and getting (or not getting) logs.

The default config for the prod environment uses a fingers_crossed handler with an action level of error, so it won't log anything unless there is a log that is at least at the error level to activate the logging in this handler (which would then also log the previous messages kept in the buffer).

Regarding the need to clear the prod cache, changing configuration files require clearing the cache in non-debug mode. There is no automatic tracking of changes in config files in non-debug mode (as the automatic refreshing requires a bunch of IO during initialization, which is far from being free in term of performance, and the prod environment is not meant to change configuration all the time but to be fast).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants