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 C2713200BD0 for ; Wed, 30 Nov 2016 11:40:46 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id C0FAD160B13; Wed, 30 Nov 2016 10:40:46 +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 16DF5160B08 for ; Wed, 30 Nov 2016 11:40:45 +0100 (CET) Received: (qmail 46331 invoked by uid 500); 30 Nov 2016 10:40:45 -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 46320 invoked by uid 99); 30 Nov 2016 10:40:45 -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; Wed, 30 Nov 2016 10:40:45 +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 93E531A92EA for ; Wed, 30 Nov 2016 10:40:44 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.3 X-Spam-Level: X-Spam-Status: No, score=0.3 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-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 6O0WyckUeUNs for ; Wed, 30 Nov 2016 10:40:42 +0000 (UTC) Received: from mxout017.mail.hostpoint.ch (mxout017.mail.hostpoint.ch [217.26.49.177]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 954355F297 for ; Wed, 30 Nov 2016 10:40:41 +0000 (UTC) Received: from [10.0.2.46] (helo=asmtp013.mail.hostpoint.ch) by mxout017.mail.hostpoint.ch with esmtp (Exim 4.87 (FreeBSD)) (envelope-from ) id 1cC2JX-0004C4-O4 for log4j-user@logging.apache.org; Wed, 30 Nov 2016 11:40:35 +0100 Received: from [2a01:48c0:200:320:d490:ea4c:afef:56e1] (helo=nb0131.netcetera.ch) by asmtp013.mail.hostpoint.ch with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.87 (FreeBSD)) (envelope-from ) id 1cC2JX-0000bl-LE for log4j-user@logging.apache.org; Wed, 30 Nov 2016 11:40:35 +0100 X-Authenticated-Sender-Id: marcel@frightanic.com Subject: Re: Switching log levels at runtime with log4j2 To: log4j-user@logging.apache.org References: <5ecdcc24-444b-2cd8-5590-93c6268d76f0@frightanic.com> <2970833f-7721-da4c-77d2-36c79491dba5@frightanic.com> From: =?UTF-8?Q?Marcel_St=c3=b6r?= Message-ID: <969fc264-a4a3-d0dd-d46c-d5614d105a23@frightanic.com> Date: Wed, 30 Nov 2016 11:40:37 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="JLE35b1v8MqOxXOsaFTNoPxQMjuCwbS0v" archived-at: Wed, 30 Nov 2016 10:40:46 -0000 --JLE35b1v8MqOxXOsaFTNoPxQMjuCwbS0v Content-Type: multipart/mixed; boundary="fGOLXMTiAlQfg3PSdeok8nvv2R0POv15S"; protected-headers="v1" From: =?UTF-8?Q?Marcel_St=c3=b6r?= To: log4j-user@logging.apache.org Message-ID: <969fc264-a4a3-d0dd-d46c-d5614d105a23@frightanic.com> Subject: Re: Switching log levels at runtime with log4j2 References: <5ecdcc24-444b-2cd8-5590-93c6268d76f0@frightanic.com> <2970833f-7721-da4c-77d2-36c79491dba5@frightanic.com> In-Reply-To: --fGOLXMTiAlQfg3PSdeok8nvv2R0POv15S Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 29.11.16 05:31, Matt Sicker wrote: > You could use the log4j-core implementation of LoggerContext.getLoggers= () > to list the current known loggers. > https://logging.apache.org/log4j/2.x/log4j-core/apidocs/org/apache/logg= ing/log4j/core/LoggerContext.html#getLoggers() Yep, that was also suggested in one of the SO answers in my initial post. I currently implemented it that way. However, LoggerContext#getLoggers() does not return parent loggers. So, if the configuration is like I'd get all com.company.* loggers but neither the com.company logger nor the root logger. I could recursively traverse that list and call getParent() on each entry (and clean duplicates) to eventually arrive at the complete set. > You could also use the JMX API for LoggerConfigAdminMBean to query the = list > of loggers. You could look at the log4j-jmx-gui source code for ideas. It uses ctx.getConfiguration().getLoggers() which, although called getLoggers(), actually returns logger configs. My conclusion is that the quickest way to obtain the complete set is to combine the results of LoggerContext#getLoggers() and LoggerContext#getConfiguration()#getLoggers(). The fact that the data types of course "don't match" is not relevant as I just the name of each anyway. --=20 Marcel St=C3=B6r, http://frightanic.com Couchsurfing: http://www.couchsurfing.com/people/marcelstoer O< ascii ribbon campaign - stop html mail - http://j.mp/1OThh9L --fGOLXMTiAlQfg3PSdeok8nvv2R0POv15S-- --JLE35b1v8MqOxXOsaFTNoPxQMjuCwbS0v Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQIcBAEBCgAGBQJYPqymAAoJELTYi6THjD3jmYUP/iihetuJ1JzCoMOAQNC+F4Qe dhUJw7nBuR9U9ptBbuM1+nxi5J8iN7C13mT+S2MXjR58200Ot85Bn/CdjavaVuNr lfylGNoN/+lAQYHXtgwS5pM6sN5cwqQxeASedSOkBLN9g7LAwLETnbM+NqyfUd8l KJnY41l8K0ZXOY0lBuB113sGOhw/JGIBgg/Fx+Jlm6HCaXc2wv3LlDPomcklhzr3 9J0gqHFcLuTWDS8ECiVYKu7PhYPz3AJ/8yPbwSz0h2ScZ2kCRbBI0xo2ma+mr1NQ 7VjJWpfTsJHNan3bqaH9KO9Cl9uVctnizLdCXCcRg9fwUfP5VQDRc7iid/Q/gRwQ SoaP240tfWe0152OR28XrjeP01QXbmGpnNc5y+n7RBYbXtgen44MUg8yt7ccXoo4 iauc5CjSUkFPEpzGlFBscGAE5oLytkjXszx+QNM1zkpRdMCBp7QlGIPL41+emya3 EidctlpHGNF0dXFA1fCF3cJPD0u2myDgVBU9l8xNIf93SINxTk7iZiyx5svv0RjK G9aFCBFHEOFTJXO3GC07R9krL0LikCI0XGeHm1EfUr4JtOQpXUeQoCoYlck6U1z/ j8SBgZizoIdW+YMczPN8JL6bBu3hQNvMr/rQp/ee3wJ0z3n26dyA+WBAOUEIPdDU W8hf1sYaBoMw/rgD8to2 =01Zs -----END PGP SIGNATURE----- --JLE35b1v8MqOxXOsaFTNoPxQMjuCwbS0v--