Skip to content

save connexion logs to file #23

Closed
Closed
@richardpatsch

Description

@richardpatsch

if I configure the logger according to the documentation and add a TimeRotatingHandler:

# Create the application instance
app = connexion.App(__name__, specification_dir='./')

json_logging.ENABLE_JSON_LOGGING = True
json_logging.init(framework_name='connexion')
json_logging.init_request_instrument(app)

logger = logging.getLogger("test-logger")
logger.setLevel(logging.DEBUG)
logger.addHandler(logging.StreamHandler(sys.stdout))

handler = TimedRotatingFileHandler('logs/info.log', 'midnight', 1, utc=True)
logger.addHandler(handler)

it only writes logger.info... logs, but not the request logs. They are only in the console.
I also tried this:

logger = logging.getLogger("connexion-request-logger")
logger.addHandler(TimedRotatingFileHandler('logs/info.log', 'midnight', 1, utc=True))

but compared to the request logs there are several fields missing (and type is "logs" instead of "request")

How is it possible write those logs to a file correctly?

thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions