Aqueduct has default preconfigured logger.
from aqueduct.logger import log
Default logger uses StreamHandler
and writes logs to stderr
Default logging level is DEBUG
You can adjust any settings of the logger by modifying it directly.
For example let's add RotatingFileHandler
to aqueduct logger and change default logging level
import logging
from logging.handlers import RotatingFileHandler
from aqueduct.logger import log
log.setLevel(logging.INFO)
handler = RotatingFileHandler('my_log.log', maxBytes=2000, backupCount=10)
log.addHandler(handler)
Another example is adding sentry handler to aqueduct logger.
You can replace default aqueduct logger with your own.
import logging
from logging.handlers import RotatingFileHandler
from aqueduct.logger import replace_logger
custom_logger = logging.getLogger(__name__)
replace_logger(custom_logger)
If you use aiohttp integration (example), you can pass your own logger to AppIntegrator
import logging
from aiohttp import web
from aqueduct.integrations.aiohttp import AppIntegrator
from .flow import get_flow
custom_logger = logging.getLogger(__name__)
def prepare_app() -> web.Application:
app = web.Application(client_max_size=0)
# Here we use logger parameter to setup our custom logger for aqueduct
AppIntegrator(app).add_flow(get_flow(), logger=custom_logger)
return app
if __name__ == '__main__':
web.run_app(prepare_app())