0

I'm trying to create logs from my Flask-RestX endpoints so I can see when they're being hit. Even with the most basic of logging configurations, I am unable to get the logs to write anywhere. I've read some conflicting articles about how Flask vs Flask-RestX deal with logging and think I may need a steer.

Here's a snippet of what I'm trying:

import logging

api = UserDto.api

logging.basicConfig(filename='myapp.log', level=logging.INFO)
logger = logging.getLogger()

@api.route('/login/', doc=False)
class Login(Resource):
    def post(self):
        try:
            logger.info("in login world")
            ...

if I place logger.info("in login world") in the class but outside of the 'post' method, it logs when the app starts up. I've printed the logger inside the method to prove it exists and knows the file location.

0 Answers0