librelist archives

« back to archive

Fwd: [flask] Logging errors in flask

Fwd: [flask] Logging errors in flask

From:
Shriram Kunchanapalli
Date:
2013-01-27 @ 06:30
ok.
In http://flask.pocoo.org/docs/errorhandling/
"Flask will display a very simple page for you and log the exception to the
logger <http://flask.pocoo.org/docs/api/#flask.Flask.logger> "
On logger i.e, http://flask.pocoo.org/docs/api/#flask.Flask.logger
logging.Logger takes you to
http://docs.python.org/dev/library/logging.html#logging.Logger

I read that
there's Logger.debug, Logger.info, Logger.warning, Logger. error

So the below's probably more correct
app.logger.setLevel(logging.DEBUG)
and
app.logger.debug('A value for debugging')
as seen in examples @ http://flask.pocoo.org/docs/api/#flask.Flask.logger




On Sun, Jan 27, 2013 at 10:15 AM, Jose Ayerdis <joseayerdis@gmail.com>wrote:

> Got it, although I realize that I had to
>
> app.logger.info('app starting up....')
>
> in order to get something in the logs.
>
> Is there a way that I can log errors like 4xx or 5xx automatically.?
>
>
> Sincerly yours,
>
> [Jose Luis Ayerdis Espinoza]
> Necronet.info | 
LinkedIn<http://www.linkedin.com/pub/jose-luis-ayerdis-espinoza/28/7b4/704>|
Careers
> StackOverflow <http://careers.stackoverflow.com/necronet>
>
>
> 2013/1/27 Shriram Kunchanapalli <kshriram18@gmail.com>
>
>>
>> 
http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-vii-unit-testing
>> In the logging to file section, there's
>> a app.logger.setLevel(logging.INFO)
>> logging.DEBUG in your case.
>> Can you try that ?
>>
>> Sent from my Windows Phone
>> ------------------------------
>> From: Jose Ayerdis
>> Sent: 27-01-2013 02:06
>> To: flask@librelist.com
>> Subject: [flask] Logging errors in flask
>>
>>  Hello I have been trying to log on DEBUG mode nevertheless when I run
>> the app the file is created but nothing is never write nor append to it. My
>> current configuratoin is this one
>>
>> import logging
>> file_handler = logging.FileHandler('kitch.log')
>> file_handler.setLevel(logging.DEBUG)
>>  file_handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s:
>> %(message)s [in %(pathname)s:%(lineno)d] [%(funcName)s() from %(module)s]'))
>> app.logger.addHandler(file_handler)
>>
>> app.run(debug=app.config['DEBUG'])
>>
>> As you can see is very straight foward, I would expect to get errorrs
>> when 404 or 401 is encounter. Any advice?
>>
>> Sincerly yours,
>>
>> [Jose Luis Ayerdis Espinoza]
>> Necronet.info | 
LinkedIn<http://www.linkedin.com/pub/jose-luis-ayerdis-espinoza/28/7b4/704>|
Careers
>> StackOverflow <http://careers.stackoverflow.com/necronet>
>>
>
>