ich den Rat der django docs gefolgt und Protokollierung wie folgt verwenden:Fertigen Sie für externe/Fremd Libs Anmeldung
import logging
logger = logging.getLogger(__name__)
def today(...):
logger.info('Sun is shining, the weather is sweet')
Mit meiner aktuellen Konfiguration sieht die Ausgabe wie folgt aus:
2016-08-11 14:54:06 mylib.foo.today: INFO Sun is shining, the weather is sweet
Leider einige Bibliotheken, die ich nicht verwenden Protokollierung wie folgt ändern:
import logging
def third_party(...):
logging.info('Make you want to move your dancing feet')
Die Ausgabe sieht leider li diese ke:
2016-08-09 08:28:04 root.third_party: INFO Make you want to move your dancing feet
Ich möchte, dies sehen:
2016-08-09 08:28:04 other_lib.some_file.third_party: INFO Make you want to move your dancing feet
Unterschied:
root.third_party ==>other_lib.some_file.third_party
Ich möchte um die lange Version zu sehen (nicht root
), wenn der Code logging.info()
anstelle von 012 verwendet
aktualisieren
Dies ist kein Duplikat Elegant setup of Python logging in Django, da die Lösung davon ist:
Anfang des Zitats
In jedem Modul definiere ich einen Logger
mitlogger = logging.getLogger(__name__)
Ende des Angebotes.
Nein, ich werde keinen Drittanbietercode ändern, der logging.info()
anstelle von logger.info()
verwendet.
Follow Up Frage
Avoid logger=logging.getLogger(__name__)
without loosing way to filter logs
https://docs.djangoproject.com/en/1.9/topics/ Logging/Sie sollten es in Ihrer settings.py konfigurieren –
Mögliche Duplikat von [Elegante Einrichtung von Python Loggi ng in Django] (http://stackoverflow.com/questions/1598823/elegant-setup-of-python-logging-in-django) –
@be_good_do_good ja, ich konfigurierte Protokollierung. Die Frage ist: Wie man Logger behandelt, die nicht mit logger = logging.getLogger (__ name __) benannt sind. – guettli