1. cherrypy
  2. CherryPy

Pull requests

#38 Merged
Repository
CherryPyCustomLogging
Branch
default
Repository
CherryPy
Branch
default

Custom logging: hostname and testcase

Author
  1. Michiel Overtoom
Reviewers
Description

Allow the letter 'o' in the custom logging string for access.log, which expands to the hostname which served the request. Useful when you are using VirtualHosts and also want to log the vhost in the logfile, for example, for analytics.

Note: This patch does not change the default CLF logfile format that CherryPy outputs; to use the vhost in the log, one has to specifically set a new log format string.

Also note that this patch does not address creating a separate logfile for every vhost; that is an entirely different functionality (and not so useful if an app serves a few thousands vhosts).

I also wrote a testcase to test the 'request.header' atoms the custom log format string (Referer, UserAgent, Host).

This patch fixes Issue #1019.

Comments (1)

  1. Sylvain Hellegouarch

    That's fine by me. Though, I would probably prefer something where the dict itself can be easily customized without having to commit anything to the repository. But as it's been quite stable, that's probably a fine patch.