Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 62AAB200B30 for ; Mon, 4 Jul 2016 22:00:52 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 6155E160A65; Mon, 4 Jul 2016 20:00:52 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 8553D160A34 for ; Mon, 4 Jul 2016 22:00:51 +0200 (CEST) Received: (qmail 6842 invoked by uid 500); 4 Jul 2016 20:00:50 -0000 Mailing-List: contact log4j-dev-help@logging.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Log4J Developers List" Reply-To: "Log4J Developers List" Delivered-To: mailing list log4j-dev@logging.apache.org Received: (qmail 6832 invoked by uid 99); 4 Jul 2016 20:00:50 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Jul 2016 20:00:50 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 2F43A1A5DBC for ; Mon, 4 Jul 2016 20:00:50 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.179 X-Spam-Level: ** X-Spam-Status: No, score=2.179 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_REPLY=1, HTML_MESSAGE=2, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx2-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id A1zbgQq8GteN for ; Mon, 4 Jul 2016 20:00:48 +0000 (UTC) Received: from mail-vk0-f51.google.com (mail-vk0-f51.google.com [209.85.213.51]) by mx2-lw-eu.apache.org (ASF Mail Server at mx2-lw-eu.apache.org) with ESMTPS id 7F51D5F46E for ; Mon, 4 Jul 2016 20:00:47 +0000 (UTC) Received: by mail-vk0-f51.google.com with SMTP id k68so154958403vkb.0 for ; Mon, 04 Jul 2016 13:00:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=aVDRy4/RHYsqKwRTq62EKamDse0vCAbA5HxQfsXk7RY=; b=fJNN+clb6X/sg0JzbxIJUxeAsa6ifQ1Ke2Pizu49Mzebzi5mIi/7AS+vAvnS+FRZxc X89ZmCpLg68EajLDSxZTCDwsH+kvzPrSBrTfzAaYylb4vR6SziZa/WPVgGLCy4EHF2iH MAajnAJu0JLxn46jet/6lkpIyh9I63a5xaGJ89iAC5GXoRA0OY4JBYiythi9dTZ3kPfO bpzhOfrKIfU29tMGRfxCB3g2Rdazlw5NJTaXwt7uB3YHJP/Q2cyk3mMoS8fDA9rPJ6cR 1xAAAHnnJ89Fz04M8+xtfZZs1iTTAiYNPSya5t9V51KPQ8jLLH9IQF28W/hsqOKkrupg eQ0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=aVDRy4/RHYsqKwRTq62EKamDse0vCAbA5HxQfsXk7RY=; b=ebz+wgxN5VctOl1YPWM1I1lJf5ddgjXnveiVZL87wdo74tcCTbgDGRb15CgSkiQERH Ox+Oxj9NB6cUSbt8PkkwiASA8HRdm007DgtR3GyHfK9WIC3cgo3EWAWL43RcVtth6vo+ k4D73wZ5WINZXo/aIqq0ii+b5OAmZQuakr9zyZPDaFaiAaFd4NWUYugLa9oHBqy9l59W /3HpGVyZEwIMAAQtsoEcdTlPyxxcWQ3TPEVu8ZOy+32HkxLcNr6dI7aQNUCMd7inrEas HTFL3KASnqumg03R+ni/7kbVGwBudT3qxYt6BSlGwWTjSzVljw71htdOPBb5GPvftO1y f8Hg== X-Gm-Message-State: ALyK8tK60pdO+JA79SKqcoU3aV1Yo2HjaFjIL3HhwRh6vKN/zIOivFnjaCRotorqbogjTLiqMbcPotDyqNqMeg== X-Received: by 10.159.54.233 with SMTP id p96mr4696728uap.96.1467662446150; Mon, 04 Jul 2016 13:00:46 -0700 (PDT) MIME-Version: 1.0 Received: by 10.176.2.212 with HTTP; Mon, 4 Jul 2016 13:00:45 -0700 (PDT) In-Reply-To: References: From: Matt Sicker Date: Mon, 4 Jul 2016 15:00:45 -0500 Message-ID: Subject: Re: Log4j should manage it's own threads To: Log4J Developers List Content-Type: multipart/alternative; boundary=94eb2c03d9a6c0cd510536d4ca41 archived-at: Mon, 04 Jul 2016 20:00:52 -0000 --94eb2c03d9a6c0cd510536d4ca41 Content-Type: text/plain; charset=UTF-8 This sounds like an interesting idea worth pursuing. On 4 July 2016 at 14:56, Gary Gregory wrote: > When I see code like: > > LOGGER.debug("RollingFileManager executing async {}", > descriptor.getAsynchronous()); > thread = new Log4jThread(new > AsyncAction(descriptor.getAsynchronous(), this)); > thread.start(); > > and: > > final Thread thread = new Log4jThread(new > ReconfigurationWorker(listener, reconfigurable)); > thread.setDaemon(true); > thread.start(); > > and other places, I think: "and poof, I've lost track of that thread". > > What if we used a thread pool (ExecutorService) to track all of our > threads? This would allow for at least trying for an orderly shutdown. This > would avoid problems like one part of an app thinking that rollovers should > be done when they are not because a log4j context has been stopped (like in > our test probably) but the rollover thread is still going about doing its > work. > > This would be for 2.7 I think. > > We could then have a different context stop API, maybe with a timeout or > not, something like ExecutorService's shutdown() vs. shutdownNow(). > > Thoughts? > > Happy 4th! > > Gary > > -- > E-Mail: garydgregory@gmail.com | ggregory@apache.org > Java Persistence with Hibernate, Second Edition > > JUnit in Action, Second Edition > Spring Batch in Action > Blog: http://garygregory.wordpress.com > Home: http://garygregory.com/ > Tweet! http://twitter.com/GaryGregory > -- Matt Sicker --94eb2c03d9a6c0cd510536d4ca41 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
This sounds like an interesting idea worth pursuing.
=

On 4 July 2016 at= 14:56, Gary Gregory <garydgregory@gmail.com> wrote:
When I see code like:
=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 LOGGER.debug("RollingFileManager executing async {}&quo= t;, descriptor.getAsynchronous());
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 thread =3D new Log4jThread(new As= yncAction(descriptor.getAsynchronous(), this));
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 thread.start();
<= div>
and:

=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 final Thread thread =3D new Log4jThread(new Reconfigur= ationWorker(listener, reconfigurable));
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 thread.setDaemon(true);
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 thread.start();

and oth= er places, I think: "and poof, I've lost track of that thread"= ;.

What if we used a thread pool (ExecutorService)= to track all of our threads? This would allow for at least trying for an o= rderly shutdown. This would avoid problems like one part of an app thinking= that rollovers should be done when they are not because a log4j context ha= s been stopped (like in our test probably) but the rollover thread is still= going about doing its work.

This would be for 2.7= I think.

We could then have a different context s= top API, maybe with a timeout or not, something like=C2=A0ExecutorService&#= 39;s shutdown() vs. shutdownNow().

Thoughts?
=

Happy 4th!

Gary

--
E-Mail: garydgregory@gmail.com | ggregory@apache.org
<= a href=3D"http://www.manning.com/bauer3/" target=3D"_blank">Java Persistenc= e with Hibernate, Second Edition
JUnit in Action, Second Edition
Spring Batch in Act= ion
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/= GaryGregory



--
Matt Sicker <boards@gmail.com>=
--94eb2c03d9a6c0cd510536d4ca41--