[Flask] Control of werkzeug logging

Scott Werner scott.werner.vt at gmail.com
Tue Jul 21 21:20:19 CEST 2015


You can disable the werkzeug logger with:

import logging
log = logging.getLogger('werkzeug')
# log.setLevel(logging.ERROR)
log.disabled = True

On Tue, Jul 21, 2015 at 1:17 PM, Jason Harris <jason at unifiedthought.com>
wrote:

> Hi I am using flask to serve an internal application on an embedded
> server. Ie the server and web page accessing the server reside on the same
> machine.
>
> I have enabled logging in my application and have something like:
>
> if __name__ == '__main__':
>   myLogger = logging.getLogger('myLogger')
>   myLogger.setLevel(logging.INFO)
>   myLoggerHandler = logging.handlers.RotatingFileHandler("mylogFile.log",
> maxBytes= 2*1024*1024, backupCount=3)
>   myLogger.addHandler(myLoggerHandler)
>   app.logger.addHandler(myLoggerHandler)
>   app.run(use_reloader=False)
>
> I want however to be able to turn off the messages that werkzeug? is
> posting with each request to flask. Ie the output is littered with
>
> 127.0.0.1 - - [18/Jul/2015 19:01:52] "GET /myPacket/ HTTP/1.1" 200 -
> 127.0.0.1 - - [18/Jul/2015 19:01:52] "GET /otherPacket/ HTTP/1.1" 200 -
> 127.0.0.1 - - [18/Jul/2015 19:01:53] "GET /otherPacket/ HTTP/1.1" 200 -
> 127.0.0.1 - - [18/Jul/2015 19:01:54] "GET /networkXYZ/ HTTP/1.1" 200 -
> 127.0.0.1 - - [18/Jul/2015 19:01:54] "GET /simulationXYZ/ HTTP/1.1" 200 -
> 127.0.0.1 - - [18/Jul/2015 19:01:54] "GET /otherPacket/ HTTP/1.1" 200 -
> 127.0.0.1 - - [18/Jul/2015 19:01:55] "GET /otherPacket/ HTTP/1.1" 200 -
> 127.0.0.1 - - [18/Jul/2015 19:01:56] "GET /networkXYZ/ HTTP/1.1" 200 -
> 127.0.0.1 - - [18/Jul/2015 19:01:56] "GET /simulationXYZ/ HTTP/1.1" 200 -
>
> Where myPacket, otherPacket, networkXYZ, simulationXYZ are routes in my
> application. How or where do I control the print out / logging of this
> information?
>
> Thanks!
>  Jason
> _______________________________________________
> Flask mailing list
> Flask at python.org
> https://mail.python.org/mailman/listinfo/flask
>



-- 
Scott Werner
scott.werner.vt at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20150721/2ac7938b/attachment.html>


More information about the Flask mailing list