I have a gunicorn application running locally, and it does log requests to a text file. What I don't understand is how to log messages to the gunicorn log file from my gunicorn application. To start my app, I use a command like % gunicorn --workers=2 test:app --reload --log-file log.txt --log-level 'debug'
I'd like to have code like this:
def app(environ, start_response):
path = environ.get("PATH_INFO")
if path == "/abc":
logging.info(f'user requested {path}')
And have gunicorn write an info log entry if that's appropriate to the level.
I checked the documentation, and I see that gunicorn uses a class gunicorn.glogging.Logger
to log, but I don't see any documentation on how to instantiate that class or use it to log my own messages.