Return-Path: X-Original-To: apmail-logging-log4j-dev-archive@www.apache.org Delivered-To: apmail-logging-log4j-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 57FD99E81 for ; Fri, 28 Sep 2012 20:27:27 +0000 (UTC) Received: (qmail 98862 invoked by uid 500); 28 Sep 2012 20:27:27 -0000 Delivered-To: apmail-logging-log4j-dev-archive@logging.apache.org Received: (qmail 98790 invoked by uid 500); 28 Sep 2012 20:27:27 -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 98780 invoked by uid 99); 28 Sep 2012 20:27:27 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Sep 2012 20:27:27 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,URIBL_DBL_REDIR X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of ralph.goers@dslextreme.com designates 209.85.214.175 as permitted sender) Received: from [209.85.214.175] (HELO mail-ob0-f175.google.com) (209.85.214.175) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Sep 2012 20:27:21 +0000 Received: by obceq6 with SMTP id eq6so3665072obc.34 for ; Fri, 28 Sep 2012 13:27:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:mime-version:content-type:subject:date:in-reply-to:to :references:message-id:x-mailer:x-gm-message-state; bh=lwKHVz3Bso2XXMv4DKq0rrpbY1E+d4WNV8/dNV0IG5M=; b=XWdjaXqCMRrOUIHcKk98kYTmjPgkLyERsjcKTFQ2KRjvb1HJUu51wqcxCUVS79eIFm lCbKq0oHCUWA31ArQsLATfO6CFiC/ZK0aokXqsEeCcdTqJr4GJpiBaDoiMSkZqOl2ZLK Sqa+t8cGzogQ7nIsUdxBeAoZuD7wIo2TPJlMQkfhqPDlp1uBaisb5xCTKj+5Mhm0weZx 0sEG8Cx8bZKJAJ4sejADO2udB15KMDm//1gpkkMWY3s3lWSgb21dQGjNnG2rCbv/D20M 4jFcH+fd853H9LFJR+HywlfOtukW0jwdOxUW0lCyUk4OEmwpuqfIC0FQHgu3GpQVBt0U omtQ== Received: by 10.60.21.167 with SMTP id w7mr6911937oee.44.1348864020876; Fri, 28 Sep 2012 13:27:00 -0700 (PDT) Received: from [192.168.1.92] (99-180-69-21.lightspeed.irvnca.sbcglobal.net. [99.180.69.21]) by mx.google.com with ESMTPS id rg10sm9238201obc.14.2012.09.28.13.26.59 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 28 Sep 2012 13:26:59 -0700 (PDT) From: Ralph Goers Mime-Version: 1.0 (Apple Message framework v1283) Content-Type: multipart/alternative; boundary="Apple-Mail=_EAF3F95C-8E03-46B8-AF8E-D5B87C9EFAD1" Subject: Re: User Story: I want to log system properties and then some. Date: Fri, 28 Sep 2012 13:26:57 -0700 In-Reply-To: To: "Log4J Developers List" References: Message-Id: X-Mailer: Apple Mail (2.1283) X-Gm-Message-State: ALoCoQnFWuqqeHTxubR7pToje2G4qOvqqoYosWo5vsGwuEE5eWGWOhvuv1acTj7JpBzKD8cXfPDR X-Virus-Checked: Checked by ClamAV on apache.org --Apple-Mail=_EAF3F95C-8E03-46B8-AF8E-D5B87C9EFAD1 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii You didn't even consider what I would think would be the obvious = solution with Log4j 2. logger.debug(new MapMessage(System.getProperties()); but that doesn't work because System.getProperties() returns a = Properties object which extends Map where the MapMessage = constructor requires Map. Still, I would focus on a = SystemPropertiesMessage or add MapMessage(Map map) to = the MapMessage before doing all the stuff you have below. Manipulating = the objects to be logged is exactly what Messages are for. Ralph On Sep 28, 2012, at 12:54 PM, Gary Gregory wrote: > Hi All: >=20 > [Preface: Some of this might seem heretic to the purist but it comes = from pragmatic experience of working with a lot of code from a lot of = different folks] >=20 > For most of my Java apps, in DEBUG mode, I log the system properties = at some point on start up.=20 >=20 > The cheap solution is the obvious: >=20 > logger.debug(System.getProperties()); >=20 > The same idea applies, depending on my app for network interfaces and = character sets. >=20 > Having one giant line is not easy to read, even in a word-wrapped = editor. >=20 > What I do instead is log one message per map entry. >=20 > I go even further and explode the entries like the classpath (but = let's KISS for now.) >=20 > This works great for the console and files but I can imagine that this = would be suboptimal for JMS. As always, caveat emptor. >=20 > Could Log4J 2.0 do something like this? >=20 > Part 1: >=20 > It is tempting to add methods like: >=20 > /** Logs one message per map entry in the form "key =3D value". */ > debugMap(Map map) > debugMap(Map map, String separator) >=20 > Part 2: >=20 > I then wonder how we could handle the explosion of map entries with = some kind of callback. >=20 > Even if we did not, and the explosion was handled in the app itself, I = would like to be able to log my exploded messages in one go with a = collection like method: >=20 > /** Logs one message per Iterable value. */ > debugAll(Iterable iterable) >=20 > Part 3: >=20 > Back to exploding an object. This seems best handled in app code = because even with some callback, all the code in the app, so nothing is = gained. >=20 > Thoughts? >=20 > Part 4: >=20 > This is lame: >=20 > logger.debug(NetworkInterface.getNetworkInterfaces()); >=20 > It outputs: >=20 > 15:47:44.624 [main] DEBUG = org.apache.logging.log4j.core.BasicLoggingTest - = java.net.NetworkInterface$1@1ccce3c >=20 > I would rather call: >=20 > /** Logs one message per Enumeration value. */ > debugAll(Enumeration enumeration) >=20 > Whatever Log4J can do for me to help me DEBUG apps without my needing = add util code over and over. >=20 > Part 5: >=20 > Most folks might not need this, but we do: >=20 > logger.debug(Charset.availableCharsets()); >=20 > If I have debugMap, then it's pretty. >=20 > Thank you reading this far! >=20 > Gary >=20 > --=20 > E-Mail: garydgregory@gmail.com | ggregory@apache.org=20 > JUnit in Action, 2nd Ed: http://bit.ly/ECvg0 > Spring Batch in Action: http://bit.ly/bqpbCK > Blog: http://garygregory.wordpress.com=20 > Home: http://garygregory.com/ > Tweet! http://twitter.com/GaryGregory --Apple-Mail=_EAF3F95C-8E03-46B8-AF8E-D5B87C9EFAD1 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii
Hi = All:

[Preface: Some of this might seem heretic to the purist but = it comes from pragmatic experience of working with a lot of code from a = lot of different folks]

For most of my Java apps, in DEBUG mode, = I log the system properties at some point on start up.

The cheap solution is the obvious:

logger.debug(System.getProperties());

The same idea applies, depending on my app for network = interfaces and character sets.

Having one giant line is not easy to read, even in a word-wrapped = editor.

What I do instead is log one message per map = entry.

I go even further and explode the entries like the = classpath (but let's KISS for now.)

This works great for the console and files but I can imagine that = this would be suboptimal for JMS. As always, caveat emptor.

Could = Log4J 2.0 do something like this?

Part 1:

It is = tempting to add methods like:

/** Logs one message per map = entry in the form "key =3D value". = */
debugMap(Map<?, ?> = map)
debugMap(Map<?, ?> map, String separator)

Part 2:

I then wonder how we could handle the explosion of = map entries with some kind of callback.

Even if we did not, and = the explosion was handled in the app itself, I would like to be able to = log my exploded messages in one go with a collection like method:

/** Logs one message per Iterable = value. */
debugAll(Iterable<?> = iterable)

Part 3:

Back to exploding an object. This = seems best handled in app code because even with some callback, all the = code in the app, so nothing is gained.

Thoughts?

Part 4:

This is = lame:

logger.debug(NetworkInterface.getNetworkInterfaces());
It outputs:

15:47:44.624 [main] DEBUG = org.apache.logging.log4j.core.BasicLoggingTest - = java.net.NetworkInterface$1@1ccce3c

I would rather call:

/** = Logs one message per Enumeration value. = */
debugAll(Enumeration<?> = enumeration)

Whatever Log4J can do for me to help me DEBUG apps = without my needing add util code over and over.

Part 5:

Most folks might not need this, but we = do:

logger.debug(Charset.availableCharsets());

If I have = debugMap, then it's pretty.

Thank you reading this = far!

Gary

--
E-Mail: garydgregory@gmail.com | ggregory@apache.org =
JUnit in Action, 2nd Ed: http://bit.ly/ECvg0
Spring Batch in Action: http://bit.ly/bqpbCK
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

= --Apple-Mail=_EAF3F95C-8E03-46B8-AF8E-D5B87C9EFAD1--