#1661 Configure python's logging module in koji's config
Closed: Fixed by tkopecek. Opened by pingou.

I would be really beneficial to be able to configure python's logging module from koji's configuration file.

For example, in koji-fedmsg-plugin we are using logging to log exceptions. However, since no handler is defined anywhere, these logs are entirely lost.
This has prevented us from finding more quickly a bug we had in this code (up until we thought about printing the exceptions).

So it would be nice if we could configure/tweak the logging configuration via koji's configuration :)

There are a few ways to do this (using ini, json, yaml) documented in the upstream's module doc: https://docs.python.org/3/howto/logging.html#configuring-logging

Thanks! :)


@pingou
"LogLevel" and "LogFormat" in /etc/koji-hub/hub.conf are for this purpose
for example:

LogLevel = koji:INFO koji-fedmsg-plugin:DEBUG
LogFormat = %(asctime)s [%(levelname)s] m=%(method)s u=%(user_name)s p=%(process)s r=%(remoteaddr)s %(name)s: %(message)s

Metadata Update from @julian8628:
- Custom field Size adjusted to None

Is this sufficient for all usecases? I've used it so far and was satisfied with that. But not sure, if it is enough for everybody.

@pingou can we close this, or do you expect something more?

I have not had to do this recently so I did not test this solution.
It does look fine though.

Maybe it would be worth ensuring it's in the koji docs somewhere? If it is we can close it for sure, otherwise, up to you :)

Metadata Update from @tkopecek:
- Custom field Size adjusted to small (was: None)
- Issue set to the milestone: 1.20
- Issue tagged with: doc

Makes sense, created PR #1739

Commit a03157d1 fixes this issue

Commit 1a2b10ae fixes this issue

Metadata Update from @jcupova:
- Issue tagged with: no_qe

This issue has been migrated to Fedora Forge:
https://forge.fedoraproject.org/koji/koji/issues/1661

Please continue any further discussion there.

Metadata
Related Pull Requests