This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 26934 - Add API to control logging, and avoid using System.xxx.print
Summary: Add API to control logging, and avoid using System.xxx.print
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: 3.x
Hardware: PC Windows ME/2000
: P1 blocker (vote)
Assignee: Martin Matula
URL:
Keywords:
: 27003 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-09-01 02:49 UTC by _ briansmith
Modified: 2002-09-06 18:11 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description _ briansmith 2002-09-01 02:49:37 UTC
When MDR is used in the NetBeans IDE, it doesn't
matter very much how much output it prints to
System.out and System.err. However, it is a
problem for command-line tools that are embedding
MDR. In particular, if a tool wants to use both
System.err and System.out to output its own
messages, and _only_ its own messages, there is
currently no way to do it. And, MDR generates
enough messages where it becomes difficult for the
user to discern between MDR's informational,
internal messages, and user-level error messages
from my command-line application.

There are workaround available (in particular, use
System.setErr() and System.setOut() to redirect
all messages to some mechanism that ignores
everything println()'d and print()'d, and provides
other methods "realPrintErr()" and "realPrintOut"
that actually send the output to the console.
However, I don't think that will always be
reasonable for every user of MDR.

There is a org.netbeans.lib.jmi.util.Log class
that seems to be intended to be used as a logging
facility for MDR, that allows a developer to
choose where to output the messages. However, it
isn't part of the official published API, so I am
reluctant to use it. Also, there are a lot of
places in the MDR code that use System.xxx.out
directly, instead of using the Log class.

It would be nice if the logging facility worked on
a callback system, so that the MDR user could
supply a callback implementation that would log
the messages appropriately. In particular, I would
like to log all the MDR messages using the JDK 1.4
logging mechanism. That implies that MDR should
always supply the messages with some kind of
indicator about severity (informational, error,
warning, etc.). Then, a callback could translate
from MDR's severity indicators and generate the
appropriate log events for the logging API of
their choice.

If some facility is added to MDR's officual API,
then I can go through the MDR source code and do
the grunt work of converting all the users of
"System.xxx.out" to use the logging facility.
Comment 1 _ briansmith 2002-09-04 19:02:56 UTC
*** Issue 27003 has been marked as a duplicate of this issue. ***
Comment 2 _ briansmith 2002-09-04 19:04:20 UTC
Also, uses of "printStackTrace" should be replaced by the logging API
(see 27003).
Comment 3 Martin Matula 2002-09-06 18:11:04 UTC
I have rewriten whole MDR to use org.openide.ErrorManager to log any
messages/exceptions.
I also added a default implementation of ErrorManager into
jmiutils.jar. This default implementation (registered by lookup) is
able to log everything into a log file (the file name can be specified
in org.netbeans.lib.jmi.Logger.fileName property). If this property
does not exist, the logger uses System.out. If you specify empty
string (i.e. -Dorg.netbeans.lib.jmi.Logger.fileName=) all logging is
suppressed.
User can also control level of severity of messages that should be
logged. A separate minimal severity can be set for JMI utils (in
org.netbeans.lib.jmi.Logger property) and for MDR library (in
org.netbeans.mdr.Logger property).