Return-Path: Delivered-To: apmail-logging-log4j-user-archive@www.apache.org Received: (qmail 23218 invoked from network); 11 Mar 2010 05:01:19 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 11 Mar 2010 05:01:19 -0000 Received: (qmail 13088 invoked by uid 500); 11 Mar 2010 05:00:46 -0000 Delivered-To: apmail-logging-log4j-user-archive@logging.apache.org Received: (qmail 12763 invoked by uid 500); 11 Mar 2010 05:00:43 -0000 Mailing-List: contact log4j-user-help@logging.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Log4J Users List" Reply-To: "Log4J Users List" Delivered-To: mailing list log4j-user@logging.apache.org Received: (qmail 12754 invoked by uid 99); 11 Mar 2010 05:00:42 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Mar 2010 05:00:42 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FREEMAIL_FROM,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of curt.arnld@gmail.com designates 209.85.160.175 as permitted sender) Received: from [209.85.160.175] (HELO mail-gy0-f175.google.com) (209.85.160.175) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Mar 2010 05:00:33 +0000 Received: by gye5 with SMTP id 5so893071gye.34 for ; Wed, 10 Mar 2010 21:00:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:content-type :mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to:x-mailer; bh=Tk/usUloDe7r/YU3gGry8ZIuy61UOHxCyvGcNlqkrI8=; b=h9Qm18DfK1Cg70VtqQXGMQAys+MeYUlxV/nSEuwkMZV3ykb+obHhWhrbDxIuL8tEjh GP1XHvgpeSWqDHONUK0BDgS+S5o/H12jFTL+bzLWD6w2BMc/TNKqfN2PbbrFpj7iXOXK TJIjvlWKGmSXxR66ac4rf7QEgB6jmBNyWpwMw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:content-type:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to:x-mailer; b=wrcRknz9z9k6HqukX3VE5vxN7LAKNqriv/Dut/aqMQPrTZsqXWaXfWAzBLj45c1Ac8 rPoPTsnphznpjKFpzsYUdHsBvfXxA2sVp7svknQnWlXl1ht8QDb5PLNIQOUtVMigHZYR NlQ4N6Z6u2d3QCcyofS9EI7ycoCFiC36Kl8t0= Received: by 10.91.79.16 with SMTP id g16mr2693002agl.90.1268283607547; Wed, 10 Mar 2010 21:00:07 -0800 (PST) Received: from [192.168.1.71] (70-139-215-122.lightspeed.cyprtx.sbcglobal.net [70.139.215.122]) by mx.google.com with ESMTPS id 22sm7344863iwn.0.2010.03.10.21.00.05 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 10 Mar 2010 21:00:06 -0800 (PST) Sender: Curt Arnold Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Apple Message framework v1077) Subject: Re: why AppenderSkeleton.doAppend is synchronized ? From: Curt Arnold In-Reply-To: <4B97CAB8.5050901@gmail.com> Date: Wed, 10 Mar 2010 23:00:03 -0600 Content-Transfer-Encoding: quoted-printable Message-Id: <3101636D-567C-45A1-BEAA-8DC0ECD32960@apache.org> References: <4B97CAB8.5050901@gmail.com> To: "Log4J Users List" X-Mailer: Apple Mail (2.1077) X-Virus-Checked: Checked by ClamAV on apache.org On Mar 10, 2010, at 10:37 AM, Stefano Nichele wrote: > Hi all, > looking for perfomance issue in my server application, I found that = AppenderSkeleton.doAppend method is synchronized. > I google a bit and I have found some messages but not a clear anwser = to my doubt: why that method is synchronized ? it seems that just check = the threshold, the filter and that "append" the event but in this way is = serializing all log calls. I'm logging events on the db and also using = AsyncAppender + my own appender I'm not able to obtain good performance = since just one thread at time can append (insert) an event and the = AsyncAppender queue grows pretty quick. >=20 > For sure i'm missing something...could you help me to understand the = root reason for having it synchronized ? I'm thinking to have my owm = implementation of AppenderSkeleton removing synchronization but I'm not = sure if there are drawbacks that im not taking in consideration. >=20 > Thanks a lot in advance > ste >=20 >=20 log4j 1.2 was designed a long time ago and relies on that big lock to = provide thread safety. Other classes in log4j (layouts, appenders and = the like) were designed assuming that they would be externally = synchronized by that lock and likely not safe if that lock is bypassed. You could either implement the Appender interface or extend = AppenderSkeleton but override doAppend (copying and pasting the = implementation but without the synchronized modifier, but all appenders, = layouts, etc used must be able to operate safely without that lock. Addressing this issue is one of the core design goals for log4j 2.0 = (http://issues.apache.org/jira/browse/LOG4J2-3)= --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org For additional commands, e-mail: log4j-user-help@logging.apache.org