[issue21495] Sane default for logging config

Thomas Guettler report at bugs.python.org
Wed May 14 06:57:14 CEST 2014


Thomas Guettler added the comment:

Thank you for reading and replying. 

Yes, I wrote no concret proposal up to now.

I have this solutions in mind:

logging.config.defaultConfig()

Related https://docs.python.org/2/library/logging.config.html


Loading a python module:
------------------------

load a module "loggingconfig" this module gets imported like any other python module. It is like django loads its settings. It could be possible to check the environment variable LOGGINGCONFIG first. It could contain a string which defaults to "loggingconfig".

This module has a method "set_up()" which sets up the logging for this environment.


Loading from a file:
---------------------

A file searched in this places:

- CWD/.loggingconfig.conf
- VIRTUAL_ENV/.loggingconfig.conf
- HOME/.loggingconfig.conf
- etc/loggingconfig.conf

The file gets loaded with fileConfig()


Module or file config loading
-----------------------------

I think the module loading is better than the file based solution. That's why I think it should be done first. If there is no module found, the file loading should be tried.

If not config found
--------------------

If not config was found, default gets set.

My proposal:
 - loglevel is set to INFO. (Debug gets suppressed)
 - format: '%(asctime)s %(name)s: %(levelname)-8s [%(process)d] %(message)s'
 - logging goes to stdout

---------------------------

What is the best way to get this into the python standard library? Should I create a PEP?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21495>
_______________________________________


More information about the Python-bugs-list mailing list