I have done all kinds of logging through .ini file and all are working fine but in HttpHandler I am not getting log message into my route.
This is my logging.ini file:
[loggers]
keys=root
[logger_root]
level=DEBUG
handlers=httpHandler
[formatters]
keys=simple
[formatter_simple]
format=%(asctime)s [%(levelname)s] %(name)s: %(message)s
[handlers]
keys=httpHandler
[handler_httpHandler]
class=handlers.HTTPHandler
formatter=simple
args=('localhost:8080','/httplogtest', 'POST')
And this is my logger.py file:
import logging
from logging.config import fileConfig
fileConfig('logging.ini')
logger = logging.getLogger()
# This message should be passed to http call
logger.info("This is INFO log")
And I want to receive this log message into my request. I just want to do this functionality through .ini file without any custom handler.
from flask import Flask
app = Flask(__name__)
@app.route('/httplogtest', methods=['GET', 'POST'])
def handle_http_log():
# I need to print this debug message here
print('Error log should be here')
It's not a duplicate question. I searched many resources but I didn't get my actual workaround to do httphandler logging from only .ini file.