0

My settings.py contains a lot of imports in try/catch blocks like:

try:
    import gcframe
except ImportError:
    # log gcframe is not available
    pass

etc.

I'd like to use Django logger to log which modules are missing, but Django docs says:

Logging is configured immediately after settings have been loaded. Since the loading of settings is one of the first things that Django does, you can be certain that loggers are always ready for use in your project code.

Is there a way to create messages (log records) in settings.py and trigger the logging of these messages after settings have been loaded?

Paolo
  • 20,112
  • 21
  • 72
  • 113
  • 1
    What is your situation where you need a large number of imports in your settings.py? – jdi Apr 22 '12 at 18:36
  • I have provided the use case. – Paolo Apr 22 '12 at 21:41
  • I think @Ignacio addresses this with his short answer. The higher level system will be the one to catch the logging as the django processing is starting. – jdi Apr 22 '12 at 21:49

1 Answers1

1

Output on stderr is caught by the higher-level system.

print >>sys.stderr, 'zOMG!'
Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358