Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #1718

=?UTF-8?B?UmU6IFN5c3RlbS5

Path csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!news.alt.net!news-in-01.newsfeed.easynews.com!easynews.com!easynews!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail
From "Lew" <lew@THRWHITE.remove-dii-this>
Subject =?UTF-8?B?UmU6IFN5c3RlbS5
Message-ID <8qGdnT31bq50lsfbnZ2dnUVZ_sWdnZ2d@comcast.com> (permalink)
X-Comment-To comp.lang.java.gui
Newsgroups comp.lang.java.gui
In-Reply-To <jJednXnkNN3fwMXbnZ2dnUVZ8vydnZ2d@bt.com>
References <jJednXnkNN3fwMXbnZ2dnUVZ8vydnZ2d@bt.com>
Content-Type text/plain; charset=IBM437
Content-Transfer-Encoding 8bit
X-Gateway time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92]
Lines 109
Date Wed, 27 Apr 2011 15:34:57 GMT
NNTP-Posting-Host 96.60.20.240
X-Complaints-To news@tds.net
X-Trace newsreading01.news.tds.net 1303918497 96.60.20.240 (Wed, 27 Apr 2011 10:34:57 CDT)
NNTP-Posting-Date Wed, 27 Apr 2011 10:34:57 CDT
Organization TDS.net
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.gui:1718

Show key headers only | View raw


  To: comp.lang.java.gui
RedGrittyBrick wrote:
> Lew wrote:
>> Piet71 wrote:
>>> In my real program I have added lots of System.out.println's from
>>
>> One trouble with System.out.println (why didn't you use System.err?) 
>> is that they have to be removed for production. 
> 
> Sorry to jump in here, I'd certainly agree that you should remove those 
> sort of statements (or make them conditional), however since output to 
> System.out is not normally visible in a jar'd Swing application (i.e. 
> when not run from an IDE or command shell) - is there any major problem 
> if they're left in?

Only the drag on performance - println() is invoked regardless of need. 
Logging libraries are optimized for minimal impact on production performance.

>> There are many reasons not to use System.out for debug or trace purposes.
> 
> I'd be interested in reading your list of those reasons.

The performance reason, ibid.  Not having the output stream cluttered with 
trace statements.

>> Why not using logging?
> 
> I can't answer for the OP, but in my case it went like this:
> 
> - System.out.println() works
>   - it needs no special classes/jars bundled with your app.

Specious.

>   - it needs no complex XML config files

Neither does log4j.

>   - it needs no class instantiation/initialisation

Neither does log4j unless you need the flexibility.

>   - it is just as easy to make conditional

No, it isn't.  The conditions add complexity to your code, instead of being 
hidden inside the logging aspect.

>   - it is just as easy to comment-out or remove using search/replace

Which is a source code change, much harder than not changing source code. 
Logging wins, since it doesn't need any code change, not commenting out nor 
removal via search/replace.

> - Logging classes seem like they're oriented to making complex
>   logging needs possible. Few of them make simple jobs simple.

I have no idea how you came up with this.  Logging libraries are dog-simple to 
use, about as complex as:

Logger logger = Logger.getLogger( getClass() );
...
logger.error( msg );

> - There's too many to choose from. Writing System.out.println()
>   a few dozen times takes a lot less gumption than studying a
>   half dozen logging classes and choosing one then using it.

I cannot believe you are touting ignorance as an excuse.  Pathetic.

Logging takes all of five minutes to learn.  Arguing that you are too lazy to 
learn it is not an indictment of the logging library but of the practitioner.

> For my limited needs I preferred to reinvent the logging wheel myself, 
> though I did feel properly guilty about it :-) I ended up with something 
> I could control by environment variables or command line params, which 
> could be used statically without configuration files or instantiation, 
> which could have logging levels set programatically if needed, and which 
> did the right thing in the absence of any configuration.

I don't see how any of that differs from, say, log4j.

> It goes without saying that it does a lot less than the more developed 
> logging classes. But I like that it's as easy to use as 
> System.out.println().

I like logging, which is as easy to use as "logger.error( msg )" and doesn't 
require re-compilation to remove them,

> I still use System.out.println() for simple programs.
> 
> I'm open to persuasion, so I'm interested to hear more details of the 
> evils of System.out.println().

Go to, say, the Apache logging page for that.  They lay the argument out 
better than I can.

You should actually learn to use, say, log4j, before you pass judgment.  By 
admitting that you haven't learned either that nor java.util.logging, you 
admit that you do not have a basis for your judgment.

Try it, you'll like it.

-- 
Lew

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

Back to comp.lang.java.gui | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

=?iso-8859-1?q?JComboBox= "Piet71" <piet71@THRWHITE.remove-dii-this> - 2011-04-27 15:34 +0000
  =?iso-8859-1?q?Re:_JCombo "Piet71" <piet71@THRWHITE.remove-dii-this> - 2011-04-27 15:34 +0000
  Re: JComboBox.setSelected "Roedy Green" <roedy.green@THRWHITE.remove-dii-this> - 2011-04-27 15:34 +0000
    =?iso-8859-1?q?Re:_JCombo "Piet71" <piet71@THRWHITE.remove-dii-this> - 2011-04-27 15:34 +0000
      Re: JComboBox.setSelected "Lew" <lew@THRWHITE.remove-dii-this> - 2011-04-27 15:34 +0000
        =?UTF-8?B?U3lzdGVtLm91dC5 "RedGrittyBrick" <redgrittybrick@THRWHITE.remove-dii-this> - 2011-04-27 15:34 +0000
          =?UTF-8?B?UmU6IFN5c3RlbS5 "Lew" <lew@THRWHITE.remove-dii-this> - 2011-04-27 15:34 +0000
            =?UTF-8?B?UmU6IFN5c3RlbS5 "RedGrittyBrick" <redgrittybrick@THRWHITE.remove-dii-this> - 2011-04-27 15:34 +0000
              =?UTF-8?B?UmU6IFN5c3RlbS5 "Lew" <lew@THRWHITE.remove-dii-this> - 2011-04-27 15:34 +0000
  =?utf-8?B?UmU6IEpDb21ib0J "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:34 +0000
    =?iso-8859-1?q?Re:_JCombo "Piet71" <piet71@THRWHITE.remove-dii-this> - 2011-04-27 15:34 +0000

csiph-web