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 197572 - NbTestCase.logRoot
Summary: NbTestCase.logRoot
Alias: None
Product: platform
Classification: Unclassified
Component: NB JUnit (show other bugs)
Version: 7.0
Hardware: All All
: P3 normal (vote)
Assignee: Jesse Glick
Depends on:
Reported: 2011-04-08 13:42 UTC by Jesse Glick
Modified: 2011-05-06 05:09 UTC (History)
1 user (show)

See Also:
Exception Reporter:

Proposed patch, minus apichanges (4.36 KB, patch)
2011-04-08 13:42 UTC, Jesse Glick
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2011-04-08 13:42:51 UTC
Created attachment 107612 [details]
Proposed patch, minus apichanges

NbTestCase.logLevel can be useful - show diagnostics only if the test actually fails, otherwise shut up.

Yet typically you do not want to get log messages from everything in the JVM. Some AWT classes are quite chatty, and org.openide.util.Mutex dumps stack traces at FINE every time you use it. The real logs from your tested code can get hidden in the mess; in fact the log is truncated around 20k, so your own logs can actually be deleted in favor of irrelevant messages.

The workaround is to turn of the root logger and turn on your own logger. But this is clumsy and error prone - you need to know how to make those calls and when (setUp?); and your own Logger you set to ALL must be held statically or it could be reset (FindBugs: LG_LOST_LOGGER_DUE_TO_WEAK_REFERENCE).

The attached patch introduces a convenience method logRoot that takes care of these issues for the common case that you are only interested in messages from a certain class (or package or package subtree).
Comment 1 Tomas Zezula 2011-04-08 19:03:23 UTC
Seems good.
Comment 2 Jesse Glick 2011-05-05 17:30:47 UTC
core-main #207f7bb76b55
Comment 3 Quality Engineering 2011-05-06 05:09:25 UTC
Integrated into 'main-golden', will be available in build *201105060000* on (upload may still be in progress)
User: Jesse Glick <>
Log: #197572: NbTestCase.logRoot may be used to refine logLevel to capture logs only from a certain part of the code.