Have you tried just a WSGI hello world with print() statements in it to
make sure nothing about any framework used is interfering.

import sys

def application(environ, start_response):
    status = '200 OK'
    output = b'Hello World!'

    print("Hi there!")

    print("Send to stdout explicitly", file=sys.stdout)

    print("Send to stderr explicitly", file=sys.stderr)

    print("stdout", type(sys.stdout))

    print("stderr", type(sys.stderr))

    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)

    return [output]




On Fri, 1 Mar 2024 at 07:50, YKdvd <[email protected]> wrote:

> I've got a Flask wsgi app, where there are print statements in the
> myapp.wsgi, which take advantage of the "send unhandled print stuff out
> through the apache error log".  This was working fine with Python
> 2.7/Ubuntu 16.04, and the output appeared in the apache error.log as
> expected.  But after conversion to Python 3.9/Ubuntu 22.04 (mod_wsgi 4.9.x,
> Flask 2.3.x, I think), the output of print() statements doesn't seem to get
> to the apache log anymore.  Later on in the request handling of the app, I
> have Python logging established (normal stdout, I think), and that output
> does get to the error log, but print() statements still don't.
>
> I assume there is some sort of change in how Python 3 is handling
> stdout/stderr, or how Flask or mod_wsgi interact with that, and the print()
> text never gets out, or goes to a bitbucket, or something, but I can't
> figure out why or how I might fix it.  I've tried a couple things to monkey
> with Python's stdout/stderr before the first print statement, but didn't
> have any luck.  I could go through and replace some of the old print
> statements with Python logging calls, but I'd like to figure this out and
> fix it if possible, if anyone has any ideas or pointers as to what might be
> happening?
>
> --
> You received this message because you are subscribed to the Google Groups
> "modwsgi" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/modwsgi/023ebed2-57ac-4a17-a9d3-567660a76aa4n%40googlegroups.com
> <https://groups.google.com/d/msgid/modwsgi/023ebed2-57ac-4a17-a9d3-567660a76aa4n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/modwsgi/CALRNbkBtfCen-6XfN%3DLqWqFSUdXVu-GPTdBfUSsCUTZAjL4mJg%40mail.gmail.com.

Reply via email to