Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #2044 (closed defect: fixed)

Opened 11 years ago

Last modified 11 years ago

'turbogears.access' logger does not conform to common/combined log format

Reported by: Chris Arndt Owned by: Chris Arndt
Priority: normal Milestone: 1.1b2
Component: TurboGears Version: 1.0.7
Severity: normal Keywords: needs review


In turbogears.controllers the RootController base class for root controllers sets up a logger named turbogears.access and defines a _cp_log_access method as a hook for CherryPy to log client requests.

It defines a log message format which is similar but not entirely conforming to  combined log format. There are two things wrong with it:

  1. If the client host name is unknown, the IP address should be logged, but it logs an empty string instead.
  2. The date is missing.

The attached patch fixes these two problems, changes the names in the log line template to be more explicit, and also uses the value of the `X-Forwarded-For' header as the client host name, if it is set, to cater for TG apps that run behind a reverse proxy.


combined-access-log.diff Download (2.1 KB) - added by Chris Arndt 11 years ago.
See ticket summary for patch description

Change History

Changed 11 years ago by Chris Arndt

See ticket summary for patch description

comment:1 Changed 11 years ago by Chris Arndt

  • Status changed from new to assigned
  • Keywords needs review added

BTW, the change should be backwards compatible, because in the quickstart template the 'turbogears.access' logger is set up to go to the 'access' logger, which uses the 'message_only' formatter, so the log messages didn't have any extra fields. The patch only adds an extra date field after the user name.

comment:2 Changed 11 years ago by faide

+1 for beta 2

comment:3 Changed 11 years ago by Chris Arndt

  • Status changed from assigned to closed
  • Resolution set to fixed

Ok, commited in r5725.

BTW, the date is always in GMT format, since there seems to be no reliable way to determine the time zone with the Python standard lib on all systems.

Note: See TracTickets for help on using tickets.