[CherryPy] #852: CherryPy always overrides user specified log levels

12 views
Skip to first unread message

CherryPy

unread,
Sep 2, 2008, 6:06:26 AM9/2/08
to cherrypy...@googlegroups.com
#852: CherryPy always overrides user specified log levels
----------------------------------------+-----------------------------------
Reporter: Bjoern (ask...@gmail.com) | Owner: fumanchu
Type: defect | Status: new
Priority: high | Milestone: 3.1
Component: CherryPy code | Keywords:
----------------------------------------+-----------------------------------
CherryPy unconditionally sets the log level for loggers used by cherrypy
to DEBUG for error logs and INFO for access logs. This may override log
levels configured by the user since this is done during startup.

From IRC:[[BR]]
[04:40am] askadar: I just want to log everything to sys.stdout, but not
the requests since the access log is being written by lighttpd anyway
[[BR]]
....[[BR]]
[04:40am] askadar: so no matter what I do the root logger, access records
are still being written to stdout[[BR]]
....[[BR]]
[04:43am] Lawouach_: setting the log.screen : False doesn't work as
expected?[[BR]]
[04:44am] askadar: I want to disable the default logging[[BR]]
[04:44am] askadar: and have only the root logger write to stdout[[BR]]
[04:44am] askadar: log.screen: False turns of all logging[[BR]]
[04:44am] askadar: by introducing the root logger with level WARNING,
cherrypy's internal stuff suddenly starts to log again,too[[BR]]
[04:44am] askadar: and that is very unexpected[[BR]]
[04:45am] Lawouach_: I see[[BR]]
[04:45am] askadar: I had hoped to filter all access records by setting the
root logger level to WARNING, since access stuff is level INFO[[BR]]
[04:45am] Lawouach_: If you think there is a design issue here you ought
to open a ticket with an alternative (patch are even better but not
mandatory [[BR]]

There is no reason why CherryPy should set these levels, especially not in
production environments. The solution is to just leave the setting alone.
Patch is attached.

--
Ticket URL: <http://www.cherrypy.org/ticket/852>
CherryPy <http://www.cherrypy.org>
CherryPy - a pythonic, object-oriented HTTP framework

CherryPy

unread,
Sep 2, 2008, 6:09:02 AM9/2/08
to cherrypy...@googlegroups.com
#852: CherryPy always overrides user specified log levels
----------------------------------------+-----------------------------------
Reporter: Bjoern (ask...@gmail.com) | Owner: fumanchu
Type: defect | Status: new
Priority: high | Milestone: 3.1
Component: CherryPy code | Resolution:
Keywords: |
----------------------------------------+-----------------------------------
Comment (by Bjoern (ask...@gmail.com)):

I forgot to mention, there is a workaround.

Execute the following function *after* cherrypy.mount() and
cherrypy.server.quickstart():
{{{
def fixup_cherrypy_logs():
loggers = logging.Logger.manager.loggerDict.keys()
for name in loggers:
if name.startswith('cherrypy.'):
print "Fixing %s." % name
logging.getLogger(name).setLevel(0)
}}}

This resets the log levels so that the final decisions is made by the root
logger.

CherryPy

unread,
Sep 27, 2008, 9:52:07 PM9/27/08
to cherrypy...@googlegroups.com
#852: CherryPy always overrides user specified log levels
----------------------------------------+-----------------------------------
Reporter: Bjoern (ask...@gmail.com) | Owner: fumanchu
Type: defect | Status: assigned
Priority: high | Milestone: 3.1
Component: CherryPy code | Resolution:
Keywords: |
----------------------------------------+-----------------------------------
Changes (by fumanchu):

* status: new => assigned

Comment:

OK. Mostly agreed. In [2046] I removed the `setLevel` calls on the Handler
objects. However, I wonder if we shouldn't keep the ones on the Logger
objects; they're easy enough to override if you want:

{{{
#!python
cherrypy.log.error_log.setLevel(logging.NOTSET)
cherrypy.log.access_log.setLevel(logging.NOTSET)
}}}

...and a similar incantation for app.log. I hesitate to make them both
NOTSET by default, since A) this would break some backward compatibility
and B) I wonder how that would interact with other libs in the same
process (say, an ORM or templating library) that also use the logging
module. Trusting them all to have similar ideas about what the various
levels mean seems brittle. Thoughts?

CherryPy

unread,
Oct 3, 2009, 5:31:24 PM10/3/09
to cherrypy...@googlegroups.com
#852: CherryPy always overrides user specified log levels
----------------------------------------+-----------------------------------
Reporter: Bjoern (ask...@gmail.com) | Owner: fumanchu
Type: defect | Status: closed
Priority: high | Milestone: 3.1
Component: CherryPy code | Resolution: fixed
Keywords: |
----------------------------------------+-----------------------------------
Changes (by fumanchu):

* resolution: => fixed
* status: assigned => closed
Reply all
Reply to author
Forward
0 new messages