logging exceptions in production?

59 views
Skip to first unread message

Juraj Variny

unread,
Sep 26, 2012, 2:21:28 PM9/26/12
to turbo...@googlegroups.com
Hi,

when there is an exception in production mode, all I get is one-line message on the console and nothing in the log file, regardless of log level. Is it possible to enable logging of exception backtraces ?
I only found a hint to install external library: https://groups.google.com/d/topic/turbogears/VFVSMaaQbgY/discussion which is not extant anymore.

Or should I wrap all my code in try blocks and log all exceptions manually?

Moritz Schlarb

unread,
Sep 26, 2012, 6:28:16 PM9/26/12
to turbo...@googlegroups.com
If you set correct email settings in your production.ini you should get the full traceback per Mail!

Michael Pedersen

unread,
Sep 27, 2012, 1:32:29 AM9/27/12
to turbo...@googlegroups.com
In addition to what Moritz said, you absolutely should be getting
tracebacks in your log files. I know that I do. What's probably
killing you, though, is the settings in your .ini file. Understanding
all of the ins and outs of configuring the Python logging module is
not always easy.

Could you post your .ini file for your applicaiton (sanitizing
passwords and other sensitive information, of course!), and I'll help
you figure out why you're not getting the info in your log files.

Thanks!
> --
> You received this message because you are subscribed to the Google Groups
> "TurboGears" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/turbogears/-/S7KDDW0YN7oJ.
>
> To post to this group, send email to turbo...@googlegroups.com.
> To unsubscribe from this group, send email to
> turbogears+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/turbogears?hl=en.



--
Michael J. Pedersen
My Online Resume: http://www.icelus.org/ -- Google+ http://plus.ly/pedersen
Google Talk: m.ped...@icelus.org -- Twitter: pedersentg

Juraj Variny

unread,
Sep 27, 2012, 10:32:57 AM9/27/12
to turbo...@googlegroups.com
Well, this is the config. I was in impression that I get no email, but cause TG neglects setting Date header, all error emails ended up in the bottom of my inbox (this should be fixed, too.)

TIA. Juraj

[DEFAULT]
debug = false
email_to = <<snip>>
smtp_server = <<snip>>
error_email_from = ser...@mydomain.com

[server:main]
use = egg:Paste#http
host = 127.0.0.1
port = 8080

[sa_auth]
cookie_secret = <<snip>>

[app:main]
use = egg:app
full_stack = false
beaker.session.type = ext:database
beaker.session.url = postgresql+psycopg2://<<snip>>
beaker.session.key = app
beaker.session.secret = <<snip>>

beaker.cache.type = ext:database
beaker.cache.url = postgresql+psycopg2://<<snip>>

sqlalchemy.url = postgresql+psycopg2://<<snip>>
sqlalchemy.echo = false
sqlalchemy.echo_pool = false
sqlalchemy.pool_recycle = 3600

templating.genshi.method = xhtml

templating.mako.reloadfromdisk = true
templating.mako.compiled_templates_dir = %(here)s/data/templates

set debug = false

toscawidgets.framework.resource_variant=min

[loggers]
keys = root, sqlalchemy, auth

[handlers]
keys = console,file

[formatters]
keys = generic

[logger_root]
level = NOTSET
handlers = console,file

[logger_sqlalchemy]
level = WARN
handlers =
qualname = sqlalchemy.engine

[logger_auth]
level = WARN
handlers =
qualname = auth

[handler_console]
class = StreamHandler
args = ()
level = NOTSET
formatter = generic

[handler_file]
class = handlers.RotatingFileHandler
args = ('app_debug.log',)
level = NOTSET
formatter = generic

[formatter_generic]
format = %(asctime)s,%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %Y%m%d %H:%M:%S


Dňa štvrtok, 27. septembra 2012 7:32:33 UTC+2 Michael Pedersen napísal(-a):

Juraj Variny

unread,
Oct 1, 2012, 3:11:20 PM10/1/12
to turbo...@googlegroups.com
It was Pylons WebError that does not put date into emails, and fix was trivial: https://github.com/Pylons/weberror/pull/4 . So at least I can use the email.

Juraj

Dňa štvrtok, 27. septembra 2012 16:32:57 UTC+2 Juraj Variny napísal(-a):
Reply all
Reply to author
Forward
0 new messages