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

Errors/warnings not logged #154

Open
dboehmer opened this issue Sep 12, 2024 · 1 comment
Open

Errors/warnings not logged #154

dboehmer opened this issue Sep 12, 2024 · 1 comment

Comments

@dboehmer
Copy link

For a long time my app has problems with errors not being logged.

Previously I used the --error-log option. Errors were not written instantly but later on some errors/warnings were written—I often didn’t see the cause when I received HTTP 500 internal server error responses myself. It always seemed like not all errors came through. I think when restarting the service sometimes errors were flushed to the log file but I definitely lost messages for HTTP 500 requests.

ExecStart=/opt/perl5/perlbrew/perls/perl-5.40/bin/starman \
    --daemonize \
    --error-log /var/log/coocook/starman.log \
    --listen /run/coocook/coocook.sock \
    --pid    /run/coocook/coocook.pid \
    /opt/coocook/coocook.psgi

In January 2024 I removed the --error-log option to make Systemd log all the errors and since then the error log has been completely empty. This is increasingly annoying since I am tryig to track down new HTTP 500 responses in production.

ExecStart=/opt/perl5/perlbrew/perls/perl-5.40/bin/starman \
    --daemonize \
    --listen /run/coocook/coocook.sock \
    --pid    /run/coocook/coocook.pid \
    /opt/coocook/coocook.psgi

The Systemd journal now looks like this repeating over and over again:

# journalctl -u coocook.service
Sep 01 10:09:25 frupa systemd[1]: Starting coocook.service - Coocook run by Starman...
Sep 01 10:09:26 frupa systemd[1]: Started coocook.service - Coocook run by Starman.
Sep 04 07:42:40 frupa systemd[1]: Stopping coocook.service - Coocook run by Starman...
Sep 04 07:42:40 frupa systemd[1]: coocook.service: Deactivated successfully.

My app is a quite complex Catalyst app with DBIx-Class that sometimes might print some warning and occasionally emits some exceptions but the PSGI process keeps running. The app is running under Debian with the most recent Perl from Perlbrew with CPAN dists installed into a local-lib dir.

Not sure if this might be related to #65 as I am not using --preload-app.

@miyagawa
Copy link
Owner

Generally speaking, PSGI servers are not supposed to log any application error messages on its own. Starman's --error-log option would only log some server-level options like some dropped connections etc.

If your application warns something, either your application framework catches it or swallows it, or it's printed to psgi.errors stream and then printed in STDERR. I think you might want to look at various errors and logging middleware to make sure the error is caught and logged on its own. e.g. https://metacpan.org/pod/Plack::Middleware::LogErrors or https://metacpan.org/pod/Plack::Middleware::LogWarn

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