Project log4j Debugging on --verbose: Difference between revisions
Jump to navigation
Jump to search
Line 8: | Line 8: | ||
This is a development pattern that routes log4j logging information to stderr if -v|--verbose command line option is used. Projects that implement it are [[clad]], [[os-stats]], etc. | This is a development pattern that routes log4j logging information to stderr if -v|--verbose command line option is used. Projects that implement it are [[clad]], [[os-stats]], etc. | ||
= | =API= | ||
Use [[novaordis-utilities]] 4.2 or newer. novaordis-utilities 4.2.0 was the first release that contains <tt>StderrVerboseLogging</tt>. | Use [[novaordis-utilities]] 4.2 or newer. novaordis-utilities 4.2.0 was the first release that contains <tt>StderrVerboseLogging</tt>. | ||
Line 29: | Line 29: | ||
... | ... | ||
</pre> | </pre> | ||
StderrVerboseLogging comes with an <tt>init()</tt> static utility method that looks at the "verbose" system property and turns on stderr logging: | |||
<pre> | |||
import io.novaordis.utilities.logging.StderrVerboseLogging; | |||
StderrVerboseLogging.init(); | |||
</pre> | |||
=Wrapper= | |||
The recommended way to pass the "verbose" information that was already identified by a bash wrapper to the JVM is to use: | The recommended way to pass the "verbose" information that was already identified by a bash wrapper to the JVM is to use: | ||
Line 44: | Line 54: | ||
command="${java_bin} ... ${verbose_system_property} ${main_class}..." | command="${java_bin} ... ${verbose_system_property} ${main_class}..." | ||
</pre> | </pre> |
Revision as of 02:09, 8 August 2016
Internal
Overview
This is a development pattern that routes log4j logging information to stderr if -v|--verbose command line option is used. Projects that implement it are clad, os-stats, etc.
API
Use novaordis-utilities 4.2 or newer. novaordis-utilities 4.2.0 was the first release that contains StderrVerboseLogging.
For more details, see:
Activate it as follows:
import io.novaordis.utilities.logging.StderrVerboseLogging; ... if (verbose) { StderrVerboseLogging.enable(); } ...
StderrVerboseLogging comes with an init() static utility method that looks at the "verbose" system property and turns on stderr logging:
import io.novaordis.utilities.logging.StderrVerboseLogging; StderrVerboseLogging.init();
Wrapper
The recommended way to pass the "verbose" information that was already identified by a bash wrapper to the JVM is to use:
-Dverbose=true
Typical bash wrapper code:
verbose=false ... ${verbose} && verbose_system_property="-Dverbose=true" command="${java_bin} ... ${verbose_system_property} ${main_class}..."