See: Description
| Interface | Description |
|---|---|
| LDLogAdapter |
An abstraction of some mechanism for producing log output.
|
| LDLogAdapter.Channel |
The underlying implementation object used by some
LDLogger instance. |
| LDLogAdapter.IsConfiguredExternally |
Marker interface indicating that this adapter is for an external framework that has its
own configuration mechanism.
|
| LogValues.StringProvider |
Functional interface for use with
LogValues.defer(com.launchdarkly.logging.LogValues.StringProvider). |
| SimpleLogging.LineWriter |
Functional interface for a method or lambda that writes a line of text.
|
| Class | Description |
|---|---|
| LDLogger |
A basic logger facade that delegates to an underlying output implementation.
|
| LDSLF4J |
An adapter for redirecting LaunchDarkly log output to SLF4J.
|
| LogCapture |
A mechanism for capturing logger output in memory.
|
| LogCapture.Message |
Information about a captured log message.
|
| Logs |
Factory methods for the basic logging implementations in this package.
|
| LogValues |
Helper methods for logging special variables.
|
| SimpleFormat |
Defines a simple parameter-substitution format, identical to the format used by SLF4J.
|
| SimpleLogging |
A basic logging implementation that formats output and sends it to an arbitrary destination.
|
| Enum | Description |
|---|---|
| LDLogLevel |
Enumeration of the logging levels defined by the LaunchDarkly logging abstraction.
|
This package provides a facade for LaunchDarkly code to write log output in a generic way without referencing any specific logging framework or third-party facade.
It does not deal with administrative tasks such as rotating log files; the assumption is that those would be set up at an OS level or by an application framework.
There are built-in implementations for basic logging: see Logs.
The API can also be connected to other logging frameworks with a simple adapter
interface, and LaunchDarkly provides several such adapters.
The reason for this indirect approach to logging is that LaunchDarkly tools can run
on both server-side Java and Android, and there is no single logging framework that
is consistently favored across all platforms. For instance, some server-side Java
applications may use SLF4J while others use
java.util.logging, and Android applications may use the native Android
logging API directly. Therefore, it's undesirable for the LaunchDarkly libraries to
have built-in dependencies on any of these. This package, with its small feature set
geared toward the needs of LaunchDarkly SDKs, aims to make the task of writing and
maintaining logging adapters very straightforward, and to reduce the chance that a
change in third-party APIs will cause backward incompatibillity.
The example code below shows how to configure the LaunchDarkly server-side SDK for Java to use some of the standard logging implementations. For more examples of how to specify a logging implementation when using the LaunchDarkly SDKs or other libraries, consult the documentation for those libraries. Each library may have its own rules for what the default logging implementation is if you don't specify one.
In this configuration, logging goes to the standard output stream (`System.out`):
LDConfig config = new LDConfig.Builder()
.logging(Components.logging(Logs.toStream(System.out)))
.build();
This is the same, except all logging below Warn level is suppressed:
LDConfig config = new LDConfig.Builder()
.logging(Components.logging(Logs.toStream(System.out).level(LDLogLevel.WARN)))
.build();
If you want to send logging to a destination that isn't built into this package,
the com.launchDarkly.logging API allows you to define your own adapter by
implementing the LDLogAdapter interface. We have
already created implementations for use with several popular logging frameworks:
LDSLF4J. Logs.toJavaUtilLogging().