python - How to disable HTTP response debug? -
my python code printing following line logs @ conclusion of every rest api call (high-level info on response sending back):
111.111.111.111 - - [15/aug/2017:12:03:15 +0000] "post /some_endpoint http/1.1" 202 72 "-" "python-requests/2.2.1 cpython/3.4.3 linux/3.13.0-83-generic"
through other searches i've seen following suggestions on how rid of it:
1) logging.getlogger('werkzeug').setlevel(logging.error)
2) logging.getlogger('werkzeug').disabled = true
3) same above, requests
instead of werkzeug
these have no effect. solution offered use different stream logging that's not going option needs.
this getting logged through separate mechanism rest of logs since format different, can't seem pinpoint culprit.
in general, can find logging
instance in library , adjust logging level
you can access logging
utility via werkzeug._internal
from werkzeug._internal import _logger
then adjust root logger logging.critical
(which 50
)
_logger.setlevel(50)
this means werkzeug
print critical
(or higher) output
you can adjust _logger
level according got needs
direct example
this applies example searching import logging
command in werkzeug
github page. found in werkzeug._internal
can do
in [2]: werkzeug.wrappers import request, response ...: ...: @request.application ...: def application(request): ...: return response('hello world!') ...: in [3]: werkzeug.serving import run_simple in [4]: run_simple('localhost', 4000, application) * running on http://localhost:4000/ (press ctrl+c quit) in [5]: werkzeug import _internal in [6]: _internal._log('info', 'setting logger level critical!') # see below why required out[6]: 'setting logger level critical!' in [7]: _internal._logger.setlevel(50) in [7]: run_simple('localhost', 4000, application)
in case _logger none
occurs because no werkzeug
logging instance has been called. see line 75 in _internal
more clarity
in [1]: werkzeug import _internal in [2]: type(_internal._logger) out[2]: nonetype in [3]: _internal._log('info', 'removing logger!') removing logger! in [4]: type(_internal._logger) out[4]: logging.logger
Comments
Post a Comment