Return-Path: Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: (qmail 22008 invoked from network); 10 Nov 2010 03:38:21 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 10 Nov 2010 03:38:21 -0000 Received: (qmail 42580 invoked by uid 500); 10 Nov 2010 03:38:52 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 42212 invoked by uid 500); 10 Nov 2010 03:38:50 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 42203 invoked by uid 99); 10 Nov 2010 03:38:49 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 10 Nov 2010 03:38:49 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of sebbaz@gmail.com designates 209.85.216.173 as permitted sender) Received: from [209.85.216.173] (HELO mail-qy0-f173.google.com) (209.85.216.173) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 10 Nov 2010 03:38:42 +0000 Received: by qyl33 with SMTP id 33so2492365qyl.18 for ; Tue, 09 Nov 2010 19:38:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=NOtXvixzQkl0FO3JYZd6aE+abdPZGUnN3o6/O7mhUIY=; b=tgkDHkREEDzqiX9i4Fsksd+Snhi6svY7azmnhsxAhflATlmOV5/6s/q7fDyDeQVxtx dZ/BrQrsIDBWFBbPobrc3r2SF7yUr9vMHaMByExc6c4gJsio/hquWiDVzJjkNtNuf8fL F21KftMYrWzMDqpnVjinsmtoffcLDByDFRx9g= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=dXZDV1MFtqHhlWpbMphh16gEJshrI3cWc7/kRxsxm9MTgtOxxUCzMvwxTbk5f5DE0N uGzx82faD0JUrPviPEimq24iy7+pzodBxa/QDlSKso0rxqtYUdaLcbzGlHp7fEWcG3wf zMW9NI1KHlC5YDLcM8yanOj9AgXXcnaDWZgGA= MIME-Version: 1.0 Received: by 10.229.189.207 with SMTP id df15mr7128100qcb.299.1289360301503; Tue, 09 Nov 2010 19:38:21 -0800 (PST) Received: by 10.229.72.94 with HTTP; Tue, 9 Nov 2010 19:38:21 -0800 (PST) In-Reply-To: <4CD9BEAB.2060003@kippdata.de> References: <4CD81450.4060200@kippdata.de> <4CD9BEAB.2060003@kippdata.de> Date: Wed, 10 Nov 2010 03:38:21 +0000 Message-ID: Subject: Re: Objections about formatting options to time stamp in access log From: sebb To: Tomcat Developers List Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org On 9 November 2010 21:35, Rainer Jung wrote: > On 08.11.2010 16:16, Rainer Jung wrote: >> >> A typical annoyance when combining Apache web server and Tomcat is the >> difference in access log timestamp. Apache logs the beginning of the >> request, Tomcat logs the end of the request. >> >> I added a feature to Apache trunk (will become 2.4) to make it >> configurable for Apache, which time stamp to choose ([1]). Furthermore >> the Apache web server allows to choose the format, in which the time >> stamp is being logged as something different than just "Common Log >> Format". This is all configured by an appropriate "format" in %{format}t= . > > ... >> >> [1] http://httpd.apache.org/docs/trunk/mod/mod_log_config.html#formats > > A first draft patch is availabel for review at > > http://people.apache.org/~rjung/patches/tomcat-trunk-accesslog-extended-t= imestamp.patch > > Status > =3D=3D=3D=3D=3D=3D > > - docs are still missing > - tested a bit also under load > - not yet tested with multiple instances of the access log The private static fields timezone and timeZone[No]DST are not final, but appear to be shared between threads. The method that creates them is synchronised, but methods that read them don't appear to be. It would be safer to make these fields final and create them in a static block (or equivalent). > - the aspect of async request handling is not clear to me. > =A0There is request.getCoyoteRequest().getStartTime() and > =A0request.setAttribute(t1Name, new Long(t1)) and I haven't > =A0checked the relation between the two at the time of logging. > > > What works > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > - %t still loggs response end time in Common Log Format > - %t{FORMAT} logs in configurable format: > =A0- FORMAT could be either "begin" or "end" or have a prefix of > =A0 =A0"begin:" or "end:", which means "use the request start time" > =A0 =A0respectively "use the response end time". > =A0- stripping the optional prefix the remaining format can be either: > =A0 =A0- one of the special tokens "sec" (seconds since epoch), "msec" > =A0 =A0 =A0(milliseconds since epoch) or "msec_frac" (only sub second > =A0 =A0 =A0milliseconds) > =A0 =A0- any other remaining format string will be passed to > =A0 =A0 =A0SimpleDateFormat > > Implementation Design > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > Common Log Format formats and SimpleDateFormat formats are cached (the ot= her > special formats are trivial to evaluate). Each different format > specification occuring in the pattern has its own cache (and > SimpleDateFormat). > > The cache is organized in two levels. A ThreadLocal caches the format for= 60 > consecutive timestamps, a global synchronized cache for 300 consecutive > timestamps. The design is more important than in the original implementat= ion > because request start times can jump more. > > All data is be consistent, i.e. begin times, end times and duration fit > together even if multiple %{FORMAT}t entries are used in the log pattern. > > Finally if a general format string is used, which gets fed into > SimpleDateFormat, I remove any "S" (milliseconds) and replace it with a > marker string. This is necessary to allow the cache to be effective. > Replacing the marker with the milliseconds is a trivial post-formatting t= as > and doesn't need complex calendar objects (I know there are leap seconds, > but well ...). > > Performance Implications > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > I did a few quick stress tests on a two CPU Sparc Server with a trivial o= ne > byte plus no sessions JSP. There was no clear difference between the old = and > the new implementation (below 5%, which one was faster was not stable, > around 7.500 requests per second for default config). > > Observations > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > The addElement() in the interface isn't very helpful. The date and time > arguments are very special for the DateAndTime and ElapsedTime formatter.= I > guess it would be better to have everything needed in request and respons= e > or pass a mre generic data object that contains additional meta data. I > didn't change any of the interfaces though, because it might not be to > unlikely that people have actually extended existing AccessLog > implementations. > > I can't work on it during the next two days, but there will be some time > during the weekend to proceed. > > Regards, > > Rainer > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org > For additional commands, e-mail: dev-help@tomcat.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org