Python 2.3 Logging Links

10 AM March 9, 2004

While the reference documentation for the Python 2.3 logging module probably tells me all I need to know to use the logging module, I am just not grokking how it should integrate into my system. In particular, initialising and configuring logging is a bit of a mystery.

A quick Google turned up these links:

  • PEP-282, authored by Vinay Sajip has a few usage examples.
By alang | # | Comments (7)
(Posted to Software Development and Python)

Comments

At 00:06, 10 Mar 2004 Andy Todd wrote:

And here is my 'quick and dirty' log function;

http://www.halfcooked.com/mt/archives/000412.html

(#)
At 07:23, 10 Mar 2004 Richard Jones wrote:

I just threw this together:

http://www.mechanicalcat.net/richard/log/index_html

hope it helps.

(#)
At 07:49, 10 Mar 2004 Alan Green wrote:

Andy, Richard,

Thanks for the tips!

a

(#)
At 12:10, 10 Mar 2004 Stuart Bishop wrote:

>>> logging.config.fileConfig('log.ini')
>>> logging.info('this is a log message to the root logger')

Unfortunately, the logging config file is quite horrible :-(

(#)
At 15:31, 10 Mar 2004 tom wrote:

fyi, if you're working with a version of python older than v2.3, you can download the logging module here and add it to your python installation:

http://www.red-dove.com/python_logging.html#download

(#)
At 11:53, 15 Mar 2004 Victor Ng wrote:

Alan - I never meant to imply you were comparing Python's docs to PHP, but I have heard it from people in the 'real' world outside of the weblog community.

What did you finally settle on for your logging configuration for your test enviroment?

All of my configuration files are placed in /etc/<myappname> by a distutils setup.py file. When my system comes up, I use ZConfig to parse /etc/myapp/app.conf. I just toss the ZConfig object to logging and get everything configured in one shot on startup.

(#)
At 21:07, 16 Mar 2004 Alan Green wrote:

Victor,

No problem, I was just being a bit cheeky back :)

Thanks for taking the time to set things straight though.

Since I don't quite know how sophisticated logging will need to be yet, I'm just putting an "import logconfig" at the top of each of my modules that does logging. The logconfig module is just ten lines of setup code - remarkably similar to the manual. Unit tests that want to turn on more logging can do so.

If I find the app need more sophisticated setup in the future, I'll still be able to drop it in. ZObject looks cool, but I'll have to put it on my list of "stuff to look at, eventually".

(#)

Add Comment




(Not displayed)






(Leave blank line between paragraphs. URLs converted to links. HTML stripped. Indented source code will be formatted with <pre> tags.)




© 2003-2006 Alan Green