wiki:LoggingConfiguration
Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Version 1 (modified by max, 13 years ago) (diff)

initial version

Starting from release 0.9a5, TurboGears supports configuring logging directly via project's configuration files.

Configuration format is mostly opaque to TurboGears - data is justed passed down to  logging module. Since configuring logging is sometimes tricky (especially for novices) here are a few recipes.

Sample #1

Say you have a project named Foobar which logs under "foobar.*" namespace. You want to:

  • separate log for all project messages, including DEBUG messages
  • separate log for all errors messages (including, but not limited to your project)
  • separate log for all non-debug messages (including, but not limited to your project)

Put the following into your prod.cfg:

[logging]

[[handlers]]
[[[debug_out]]]
class='FileHandler'
formatter='full_content'
args="('foobar-debug.log', 'a+')"

[[[error_out]]]
level='WARN'
class='FileHandler'
formatter='full_content'
args="('foobar-errors.log', 'a+')"

[[[access_out]]]
level='INFO'
class='FileHandler'
formatter='full_content'
args="('foobar-info.log', 'a+')"

[[loggers]]
[[[your_project]]]
level='DEBUG'
qualname='foobar'
handlers=['debug_out']

[[[access]]]
level='INFO'
handlers=['access_out', 'error_out']

You may want to tweak filenames to be absolute.