Return-Path: X-Original-To: apmail-tomcat-dev-archive@www.apache.org Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3684D6D81 for ; Mon, 20 Jun 2011 16:53:13 +0000 (UTC) Received: (qmail 18166 invoked by uid 500); 20 Jun 2011 16:53:12 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 18087 invoked by uid 500); 20 Jun 2011 16:53:12 -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 18078 invoked by uid 99); 20 Jun 2011 16:53:12 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 Jun 2011 16:53:12 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of knst.kolinko@gmail.com designates 209.85.212.45 as permitted sender) Received: from [209.85.212.45] (HELO mail-vw0-f45.google.com) (209.85.212.45) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 Jun 2011 16:53:07 +0000 Received: by vws17 with SMTP id 17so3756548vws.18 for ; Mon, 20 Jun 2011 09:52:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=n287ms9dATruxxzAf9ZHvfYHwdx+y9xgxnEnvaW1IPM=; b=aRaAk1s+E1QR7wMNtQMOEBz3YFXcBGWTswaW/ko1JMeAuk1nIFJ/QCy38p0Zaq4v5P qi0nrLJFx1I44EWwvLX8oV3STA2hS+OWEpRhGm2mudW8EjcjEcWspmKOEW2DRqJvNyOM XSWIDuukrDbiofM61x6tIcmlHt5l5p6CMMzWM= 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; b=r+794yESZXrvCx9+wBT1qoQkHAmzsxn5NEkkQUEwBtn2Z2YOz/DlNgKVwyAJ0BvXfh 4ngMPr/tPbBqZyksOP01CG7RtHxj+YzE1ce9yYORCiSd7wBlSAWdDFtnEZSy9bOE7o0M kTua2FWRVtMYoCWlDNKmp/XvZnwhqIfjimcEo= MIME-Version: 1.0 Received: by 10.52.65.43 with SMTP id u11mr2588512vds.302.1308588766717; Mon, 20 Jun 2011 09:52:46 -0700 (PDT) Received: by 10.52.164.41 with HTTP; Mon, 20 Jun 2011 09:52:46 -0700 (PDT) In-Reply-To: <4DFF5E6A.2040300@kippdata.de> References: <4DFF5E6A.2040300@kippdata.de> Date: Mon, 20 Jun 2011 20:52:46 +0400 Message-ID: Subject: Re: OneLineFormatter by default? From: Konstantin Kolinko To: Tomcat Developers List Content-Type: text/plain; charset=ISO-8859-1 2011/6/20 Rainer Jung : > Should we use the new OneLineFormatter as the default juli formatter? > > I never found anyone who liked the default java.util.logging log format, > which spreads all messages out via two lines. One line contains the > timestamp, the other line the message. > > So if your grep for a message, you want find out when it was issued, and > if you look for a certain time range, yout wont see the actual messages. > Non-sense. > > Now that we have our nice little OneLineFormatter, why not use it as > default? > I like the default SimpleFormatter. With the SimpleFormatter those messages fit better when they are printed into console window. It is easier to read through the log files as well. With OneLineFormatter the messages are shifted to the right. The offset is arbitrary, because class names before the message have arbitrary length. Enabling line wrapping in file viewer is possible, but does not make those lines more readable. It is hard to read. I think SimpleFormatter should stay as the default. Some nitpicks looking at the source code of OneLineFormatter. 1) OneLineFormatter#currentDate and currentDateString are used in double locking. If I understand it correctly, the should be made volatile. Though see the next point. 2) I do not understand why OneLineFormatter#addTimestamp( ) method is public. It could be protected. It is not used anywhere else. Furthermore, the only place where it is called, the #format() method, always creates a new instance of Date object. Thus "if (currentDate != date)" comparison of object instances does not make sense. 3) msec value looses its leading zero. E.g. in two subsequent lines: 20-Jun-2011 20:25:25.46 20-Jun-2011 20:25:25.531 4) SimpleFormatter#format() delegates message formatting to Formatter#formatMessage(..) which performs lookup through a resource bundle and does formatting of parameters. OneLineFormatter does not do it. It just uses the message as String. It is not of much difference for Tomcat, because Tomcat does not use java.util.logging directly, but some other webapps may use it. (Not a very strong argument though). > If we use it as default: should be have it as default without config, > i.e. as a default in code, or do we want to add the .formatter lines to > our loggging.properties? Or add the formatter system property to > catalina.properties? > > I think I would favor having it as a code default, i.e. without any > configuration. > In the code you can change default for the JULI's FileHandler only. (Unless you tweak properties loading itself). There are other Handler implementations there. If it were changed I'd prefer it to be in the configuration. Regarding grep: Some grep implementations (e.g. the GNU one) have --context, --before-context, --after-context options to print several lines of context for each match (section 2.1.5 in [1]). [1]: http://www.gnu.org/software/grep/manual/ Best regards, Konstantin Kolinko --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org