How to check python-logging logs in a Docker container micro-service

How to check python-logging logs in a Docker container micro-service

Asked on May 2, 2019 in Python.
Add Comment


  • 3 Answer(s)

    Working on a project coded by another developer.In the project Docker container, I have 3 micro-services (aggregatore, classificatore, testmicro),
    each using python module logging for debugging purposes.

    Answered on May 2, 2019.
    Add Comment
    from flask import Flask, jsonify, request
    import redis
    app = Flask(__name__)
    @app.route(/)
    def default_route():
    “””Default route to return a simple message“””
    return jsonify(hello world)
    @app.route(/message, methods=[GET])
    @app.route(/message/<new_message>, methods=[POST])
    def message_handler(new_message=None):
    “””Handle the getting and setting of the message“””
    redis_client = redis.StrictRedis(host=redis)
    if request.method == GET:
    output = redis_client.get(message)
    # import pdb; pdb.set_trace()
    if output:
    return jsonify(dict(message=output.decode(utf-8)))
    return jsonify(dict(message=no output found for new_message))
    redis_client.set(message, new_message)
    return jsonify(dict(message=set new_message))
    if __name__ == __main__:
    app.run(0.0.0.0, 8000, debug=True)
    Answered on May 20, 2019.
    Add Comment
    class LogsCollection(Resource):
        def post(self):
            """Receives a log."""
            log.handle(logging.makeLogRecord(request.get_json()))
            return None, 201
    Answered on May 20, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.