Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 June 23, 2010 16:48:42

t.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Django logging


Hi,

I am creating a new django framework and figured django would come
with its own logging feature. I found this one that Fraser wrote but
is no longer in development (http://code.google.com/p/django-logging/wiki/Overview) Can anyone suggest me a django logging project to log
debug/error messages at server level and as a bonus feature perhaps an
email to admin if a critical error happens.

Cheers,
Nathan.

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#2 June 23, 2010 18:07:54

David D.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Django logging


On 23/06/10 16:48, thusjanthan wrote:Hi,

I am creating a new django framework and figured django would come
with its own logging feature. I found this one that Fraser wrote but
is no longer in development (http://code.google.com/p/django-logging/wiki/Overview)That's wasn't really for logging in the operational server system logssense, it was for showing log messages arising in the request-responsecycle in the html returned to the browser (which IS very handy duringdevelopment/debug, but not something you'd do on a production server...).django-debug-toolbar has a superset of its functionality.Can anyone suggest me a django logging project to log
debug/error messages at server level and as a bonus feature perhaps an
email to admin if a critical error happens.Python itself ships with a logging infrastructure (quite the baroqueone), module "logging". You can just use that in conjunction with django.http://docs.python.org/release/2.6/library/logging.htmlregarding email: Django does fire off certain exception emails whendisaster strikes, python logging has SMTPHandler, and there's also the"logwatch" tool once you have stuff going to logs.###So, most of our django app's python files do something like thefollowing near the top:# say for the models.py in a django app "accounts"
import logging
_log = logging.getLogger('accounts.models')

# and then use

_log.error("ohno")
_log.warning("grr")
_log.info("hey")
_log.debug("soturnsout")We use the leading underscore on the module-level _log so that A doesn'tpick up B's logger if A does a "from B import *" !###We then init python's logging in a vaguely django-project-useful fashionin a function called from our settings.py or somewhere similarly early(you may need to take steps to make sure to only register the handlersonce per process, say a global "configured" var)e.g. (not precisely the code we use, untested):

# prefix is just a per-project prefix we set, that way two
# instances of the same app in two different projects are
# distinguishable in combined logging.

# root logger for argument's sake
# you might want something else, see logging docs
rl = logging.getLogger('')

# Stuff you send to stderr with mod_wsgi does end up in the apache log,
# though maybe it's not the best option.streamformatter = logging.Formatter("django: %(levelname)s:%(name)s: %(message)s")streamhandler = logging.StreamHandler() # defaults to stderr
streamhandler.setLevel(logging.WARNING)
streamhandler.setFormatter(streamformatter)
rl.addHandler(streamhandler)

# and/or you could send to syslogslformatter = logging.Formatter("django: %(levelname)s: %(name)s: %(message)s")sysloghandler = logging.handlers.SysLogHandler(address='/dev/log',facility=logging.handlers.SysLogHandler.LOG_DAEMON)sysloghandler.setLevel(logging.WARNING)
sysloghandler.setFormatter(slformatter)
rl.addHandler(sysloghandler)


# And/or to a file
# N.B. python 2.5 lacks WatchedFileHandler, but it's an easy backport
# from 2.6 sources.

# base some base file path+namefformatter = logging.Formatter(" django:%(levelname)s: %(name)s: %(message)s")h = WatchedFileHandler(base + ".log", encoding='utf-8')
h.setLevel(logging.INFO)
h.setFormatter(fformatter)
rl.addHandler(h)
e = WatchedFileHandler(base + ".err", encoding='utf-8')
e.setLevel(logging.ERROR)
e.setFormatter(fformatter)
rl.addHandler(e)

if settings.DEBUG:debugformatter = logging.Formatter("django: %(levelname)s: %(name)s:%(pathname)s(%(lineno)d): %(message)s")d = WatchedFileHandler(base + ".dbg", encoding='utf-8')
d.setLevel(logging.DEBUG)
d.setFormatter(debugformatter)
rl.addHandler(d)


# See logging docs for more.

--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#3 June 24, 2010 00:28:21

Russell K.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Django logging


On Thu, Jun 24, 2010 at 1:07 AM, David De La Harpe Golden
<david.delaharpe.gol...@ichec.ie> wrote:
> On 23/06/10 16:48, thusjanthan wrote:
>>
>> Hi,
>>
>> I am creating a new django framework and figured django would come
>> with its own logging feature. I found this one that Fraser wrote but
>> is no longer in development (http://code.google.com/p/django-logging/>> wiki/Overview)
>
> That's wasn't really for logging in the operational server system logs
> sense, it was for showing log messages arising in the request-response cycle
> in the html returned to the browser (which IS very handy during
> development/debug, but not something you'd do on a production server...).
>
> django-debug-toolbar has a superset of its functionality.
>
>>  Can anyone suggest me a django logging project to log
>> debug/error messages at server level and as a bonus feature perhaps an
>> email to admin if a critical error happens.
>>
>
> Python itself ships with a logging infrastructure (quite the baroque one),
> module "logging".  You can just use that in conjunction with django.
>
>http://docs.python.org/release/2.6/library/logging.html>
> regarding email:  Django does fire off certain exception emails when
> disaster strikes, python logging has SMTPHandler, and there's also the
> "logwatch" tool once you have stuff going to logs.

I would also add that adding support for logging is one of the high
priority items for Django 1.3 . The design is mostly sorted at this
point, and a preliminary implementation is available at

http://code.djangoproject.com/tickets/12012https://code.launchpad.net/~vinay-sajip/django/loggingYours,
Russ Magee %-)

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#4 June 24, 2010 03:03:09

Andy M.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Django logging


On 2010-06-23, at 8:48 AM, thusjanthan wrote:
> I am creating a new django framework and figured django would come
> with its own logging feature. I found this one that Fraser wrote but
> is no longer in development (http://code.google.com/p/django-logging/> wiki/Overview) Can anyone suggest me a django logging project to log
> debug/error messages at server level and as a bonus feature perhaps an
> email to admin if a critical error happens.

Give Arecibo a look.http://www.areciboapp.com/http://www.areciboapp.com/docs/client/django.htmlhttp://www.agmweb.ca/blog/andy/2268/etc...

Cheers
--
Andy McKay, @andymckay
Django Consulting, Training and Support

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

Board footer

Moderator control

Enjoy the 15th of December
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support