public class RedwoodConfiguration
extends java.lang.Object
If you wish to turn off Redwood logging messages altogether you can use:
RedwoodConfiguration.current().clear().apply();
.
If you need to suppress messages to stderr in a block, you can use:
// shut off annoying messages to stderr
RedwoodConfiguration.empty().capture(System.err).apply();
// block of code that does stuff
// enable stderr again
RedwoodConfiguration.current().clear().apply();
Alternatively, if Redwood is logging via slf4j (this is the default, if slf4j is present on your classpath),
then you can configure logging using the usual slf4j configuration methods. See, for example,
this StackOverflow
question. For example, you can add a Properties file simplelogger.properties
to your classpath
with the line org.slf4j.simpleLogger.defaultLogLevel=error
and then only ERROR messages will be
printed.
Modifier and Type | Class and Description |
---|---|
static class |
RedwoodConfiguration.Handlers |
static interface |
RedwoodConfiguration.Thunk |
Modifier | Constructor and Description |
---|---|
protected |
RedwoodConfiguration()
Private constructor to prevent use of "new RedwoodConfiguration()"
|
Modifier and Type | Method and Description |
---|---|
void |
apply()
Apply this configuration to Redwood
|
static void |
apply(java.util.Properties props)
Parses a properties file and applies it immediately to Redwood
|
RedwoodConfiguration |
capture(java.io.OutputStream stream)
Capture a system stream.
|
RedwoodConfiguration |
channelWidth(int width)
Set the width of the channels (or 0 to not show channels).
|
RedwoodConfiguration |
clear()
Clear any custom configurations to Redwood
|
static RedwoodConfiguration |
current()
The current Redwood configuration; this is used to make incremental changes
to an existing custom configuration.
|
static RedwoodConfiguration |
debugLevel()
Run Redwood with SLF4J if available, otherwise with stderr logging at the debug (everything) level.
|
static RedwoodConfiguration |
empty()
An empty Redwood configuration.
|
static RedwoodConfiguration |
errorLevel()
Run Redwood with SLF4J if available, otherwise with stderr logging at the error only level.
|
RedwoodConfiguration |
handlers(RedwoodConfiguration.Thunk... paths)
Add handlers to Redwood.
|
static RedwoodConfiguration |
infoLevel()
Run Redwood with SLF4J if available, otherwise with stderr logging at the warning (and error) level.
|
static RedwoodConfiguration |
javaUtilLogging()
Run Redwood with java.util.logging
|
RedwoodConfiguration |
listenOnChannels(java.util.function.Consumer<Redwood.Record> listener,
java.lang.Object... channels) |
static RedwoodConfiguration |
minimal()
The default Redwood configuration, which prints to the console without channels.
|
RedwoodConfiguration |
neatExit()
Close tracks when the JVM shuts down.
|
RedwoodConfiguration |
output(java.lang.String method)
Determine where, in the end, console output should go.
|
static RedwoodConfiguration |
parse(java.util.Properties props)
Configure Redwood (from scratch) based on a Properties file.
|
RedwoodConfiguration |
restore(java.io.OutputStream stream) |
static RedwoodConfiguration |
slf4j()
Run Redwood with SLF4J as the console backend
|
static RedwoodConfiguration |
standard()
A standard Redwood configuration, which prints to the console with channels.
|
protected RedwoodConfiguration()
public void apply()
public RedwoodConfiguration capture(java.io.OutputStream stream)
stream
- The stream to capture; one of System.out or System.errpublic RedwoodConfiguration restore(java.io.OutputStream stream)
public RedwoodConfiguration listenOnChannels(java.util.function.Consumer<Redwood.Record> listener, java.lang.Object... channels)
public RedwoodConfiguration output(java.lang.String method)
method
- An output, one of: stdout, stderr, or java.util.loggingpublic RedwoodConfiguration channelWidth(int width)
width
- The left margin in which to show channelspublic RedwoodConfiguration clear()
public RedwoodConfiguration handlers(RedwoodConfiguration.Thunk... paths)
handlers(branch( chain( hideDebug, collapseApproximate, branch( output, file("stderr.log") ), chain( showOnlyError, file("err.log") ). chain( showOnlyChannels("results", "evaluate"), file("results.log") ), chain( file("redwood.log") ), noop))
paths
- A number of paths to add.public RedwoodConfiguration neatExit()
public static RedwoodConfiguration empty()
public static RedwoodConfiguration standard()
public static RedwoodConfiguration minimal()
public static RedwoodConfiguration slf4j()
apply()
.public static RedwoodConfiguration debugLevel()
apply()
.public static RedwoodConfiguration infoLevel()
apply()
.public static RedwoodConfiguration errorLevel()
apply()
.public static RedwoodConfiguration javaUtilLogging()
apply()
.public static RedwoodConfiguration current()
public static RedwoodConfiguration parse(java.util.Properties props)
props
- The properties to use in configurationpublic static void apply(java.util.Properties props)
props
- The properties to apply