Where do the fingerprints go when running Flask with Apache?

I just deployed the first website that I created with Flask to a production server. I turned on logging using logging.handlers.RotatingFileHandler to /log/myapp.log , with which I can log messages using, for example:

 current_app.logger.error('this is a massive error') 

It works great. This makes me think about some code fragments, although they contain, for example, print 'some info here' , which I used during debugging. Where do these printouts go? Into the void /dev/null or somewhere else? Is it possible to catch them?

All tips are welcome!

+6
source share
2 answers

Everything that you print with print goes to standard output, i.e. /dev/stdout to the Unix server (default). Since apache is running as a service, you probably will never see this output.

One way to solve this problem is to redirect the standard output of your scripts to some files:

 >>> import sys >>> sys.stdout = open('output.logs', 'w') >>> print('Hello World!') # Nothing appears bellow >>> sys.stdout = sys.__stdout__ # Reset to the standard output >>> open('output.logs', 'r').read() 'Hello World!\n' 
+4
source

Printing operations in an application running on apache can usually be seen in Apache logs. You can check this file: /var/log/apache2/other_vhosts_access.log

+2
source

All Articles