Return-Path: X-Original-To: apmail-cxf-dev-archive@www.apache.org Delivered-To: apmail-cxf-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 28F95DD25 for ; Sun, 30 Sep 2012 18:32:45 +0000 (UTC) Received: (qmail 75235 invoked by uid 500); 30 Sep 2012 18:32:44 -0000 Delivered-To: apmail-cxf-dev-archive@cxf.apache.org Received: (qmail 75181 invoked by uid 500); 30 Sep 2012 18:32:44 -0000 Mailing-List: contact dev-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list dev@cxf.apache.org Received: (qmail 75173 invoked by uid 99); 30 Sep 2012 18:32:44 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 30 Sep 2012 18:32:44 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of sberyozkin@gmail.com designates 74.125.83.41 as permitted sender) Received: from [74.125.83.41] (HELO mail-ee0-f41.google.com) (74.125.83.41) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 30 Sep 2012 18:32:38 +0000 Received: by eekc4 with SMTP id c4so2513385eek.0 for ; Sun, 30 Sep 2012 11:32:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=S58ItF8Avw+7eivb6vCV0OR+LPmbTtoaAwbVb/tQq7g=; b=qvcrH761KaYX7FmIJvqsrgxNefKZnCL1GIJHmHSgQMecEN499Muh7iBwmh+O2QGDZ9 NFKBrUIRA6x4rIg6cUghCmE2+/5U1QWm1uc9pjECGe1btpl+4+FsVSf4xng6r8QJhVHd ZLRL9YSrIodUmRftGYKwaoZQl5LiLQnJB5fCUZ0KVWHeOmjhW7R45rjITkbStNPzUGx5 2X/fFqNOdk4R+S9e8Nhhgl3xuEkTIjnHC25DOZEkwdr5W1IeF8bcY9171ZfMhvYQ33hQ 1POX9XBgBJqv3Ns4Dd9krWTpCFWjydMq50pJOZ3/3kgccbjMVt5micBFWdoYZLqLMemN 8KaQ== Received: by 10.14.198.133 with SMTP id v5mr15777376een.7.1349029937347; Sun, 30 Sep 2012 11:32:17 -0700 (PDT) Received: from [192.168.2.5] ([89.100.141.71]) by mx.google.com with ESMTPS id i1sm8400917eeo.8.2012.09.30.11.32.16 (version=SSLv3 cipher=OTHER); Sun, 30 Sep 2012 11:32:16 -0700 (PDT) Message-ID: <5068902F.809@gmail.com> Date: Sun, 30 Sep 2012 19:32:15 +0100 From: Sergey Beryozkin User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 MIME-Version: 1.0 To: Benson Margulies CC: dev@cxf.apache.org Subject: Re: Some issues with logging and tests References: <50687A7A.9030601@gmail.com> <506883BE.7010504@gmail.com> In-Reply-To: <506883BE.7010504@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Also updated the mapper to optionally report an error message (can be customized by extending the mapper) by setting an 'addMessageToResponse' property - which is ignored if the exception already contains Response with a non-null entity Sergey On 30/09/12 18:39, Sergey Beryozkin wrote: > Hi > On 30/09/12 18:03, Benson Margulies wrote: >> On Sun, Sep 30, 2012 at 12:59 PM, Sergey >> Beryozkin wrote: >>> On 30/09/12 14:33, Benson Margulies wrote: >>>> >>>> I've got a case, for which I'm about to file a JIRA, in which I think >>>> that it's important that a particular situation leads to a log message >>>> with some minimal content with a particular log level. Have we got any >>>> tests for cases like this? I'm thinking about wiring up some sort of >>>> test rig for intercepting log messages for the purpose. >>>> >>>> Meanwhile, this particular case is perhaps worth a moment's discussion. >>>> >>>> In JAX-RS, consider the following circumstance: >>>> >>>> A resource accepts a parameter of bean type, and a mapper (in my case, >>>> the Jackson json mapper) is responsible for mapping from the incoming >>>> content to the bean. The incoming headers specify 'accept: >>>> application/json', since that's what the function (normally) produces. >>>> >>>> Now, someone debugging a python client sends a json blob with a >>>> misspelled item in it. The mapper throws an exception. >>>> >>>> WebApplicationExceptionMapper catches it and maps it to a 500, >>>> accompanying the action with a log message at DEBUG. >>>> >>>> The client gets a naked '500', no message anywhere. I suspect, but I'm >>>> not sure, that the mapper would send back some backtracey verbiage if >>>> the accept header were no so restrictive. >>>> >>>> On the one hand, a WARN would be handy, as it's a pain to have to go >>>> adjust the logging config just to see why the client isn't working. On >>>> the other hand, a production application might get thousands of >>>> malformed inputs a day, and might not want all this traffic in the >>>> log. >>>> >>>> Do we have a design principle (written down?) about how we decide what >>>> should be logged non-DEBUG? Should errors resulting from ill-behaved >>>> clients get that treatment? If not, I shouldn't write a JIRA or change >>>> any code here. >>> >>> As I said in the previous message, it is to do with the >>> over-optimization of >>> WebApplicationExceptionMapper. >>> >>> By the way, I'm not sure I agree with the fix to CXF-4528. >>> This is now getting complicated: one has to install a fault logger to >>> get a >>> stack trace, and, on top of that, the logging will happen twice, if >>> property >>> is set and FINE is active... >> >> That was the situation *before* I changed it. As of now, if there's no >> fault logger, you have a stack trace if you make the call to turn on >> the stack trace. If you *do* decide to put in a fault logger, you >> decide whether to dump stack traces from it. >> >>> >>> Let me propose something slightly different: if the fault logger is >>> installed and it handled the exception: then do nothing else, the >>> logger can >>> log or ignore the error message, if not - do print the warn message >>> because >>> a number of times this issue has been raised - and this can be >>> optimized if >>> needed by turning 'printStackTrace' to false. >> >> That's what I did, except that I left it at 'FINE'. If I messed up the >> logic let's look at the code together. >> > Sounds good, what do you think of r1392082 ? > Basically, right now the logic is as follows: > > If the fault listener is available and has indicated it did handle the > call - then do nothing else, otherwise - do either WARN (default) or > FINE print stack trace message > > I guess there could be more variations (as to what to do when the fault > listener has handled or has not handled the call - the logic can be > improved), but I guess I'd like to make sure the user can get a print > stack trace without having to install a listener... > > Thanks, Sergey -- Sergey Beryozkin Talend Community Coders http://coders.talend.com/ Blog: http://sberyozkin.blogspot.com