[Twisted-web] twisted log files

Manlio Perillo manlio_perillo at libero.it
Sun Dec 10 11:23:47 CST 2006


Jean-Paul Calderone ha scritto:
> On Sun, 10 Dec 2006 12:55:18 +0100, Manlio Perillo 
> <manlio_perillo at libero.it> wrote:
>> Noah Gift ha scritto:
>>> I am not sure if awstats directly parses twisted log files,
>>
>> I'm rather sure that it can not parse Twisted log file but there are 
>> two solution:
> 
> Twisted Web will produce apache common log formatted logfiles if you ask
> it to.  Look at the arguments Site takes.
> 


twisted.web.server.Site:
    def __init__(self, resource, logPath=None, timeout=60*60*12):
  	        """Initialize.
  	        """

I can't see any options for changing log format.

The only thing I can change is the log method in HTTPFactory:

     def log(self, request):
         """Log a request's result to the logfile, by default in 
combined log format."""
         if hasattr(self, "logFile"):
             line = '%s - - %s "%s" %d %s "%s" "%s"\n' % (
                 request.getClientIP(),
                 # request.getUser() or "-", # the remote user is almost 
never important
                 _logDateTime,
                 '%s %s %s' % (self._escape(request.method),
                               self._escape(request.uri),
                               self._escape(request.clientproto)),
                 request.code,
                 request.sentLength or "-",
                 self._escape(request.getHeader("referer") or "-"),
                 self._escape(request.getHeader("user-agent") or "-"))
             self.logFile.write(line)


The combined log format should be supported by awstats.



Regards  Manlio Perillo




More information about the Twisted-web mailing list