aiohttp how to log access log?
<p>I am trying to get a basic logger for aiohttp working, but there are simply no log messages being logged. Note_ logging custom messages works as expected.</p>

<pre><code>async def main_page(request: web.Request):
    return "hello world"

def setup_routes(app):
    app.router.add_get('/', main_page)


async def init(loop):
    # load config from yaml file in current dir
    conf = load_config(str(pathlib.Path('.') / 'async_config.yml'))

    # setup application and extensions
    app = web.Application(loop=loop)

    # setup views and routes
    setup_routes(app)

    host, port = conf['host'], conf['port']

    app['gmt_file'] = _get_gmt_file()

    return app, host, port

    LOG_FORMAT = '%a %l %u %t "%r" %s %b "%{Referrer}i" "%{User-Agent}i"'
    log_file = "log.text"
    handler = handlers.TimedRotatingFileHandler(log_file, when='midnight',
                                                backupCount=5)

    handler.setLevel(logging.DEBUG)
    formatter = logging.Formatter(LOG_FORMAT)
    handler.setFormatter(formatter)
    handler.name = "file_log"

    loop = asyncio.get_event_loop()
    app, host, port = loop.run_until_complete(init(loop))

    logging.getLogger("aiohttp").addHandler(handler)

    # todo host ziehen per aiohttp methods, so we are externally visible.
    web.run_app(app, host=host, port=port)
</code></pre>

<p><code>LOG_FORMAT</code> should be "%s" if any.
<code>'%a %l %u %t "%r" %s %b "%{Referrer}i" "%{User-Agent}i"'</code> is a valid parameter for <code>.make_handler(access_log_format=...)</code> call, not <code>logging.Formatter</code>.</p>

<p>As first step I suggest setting up root logger and after that going down to error/access logs.
Perhaps access log worth own private file like <code>access.log</code>. To achieving this you need to setup a handler for <code>aiohttp.access</code> logger, not for top-level <code>aiohttp</code>.</p>

python aiohttp