- All Known Implementing Classes:
ConsoleLogging
,DevNullLogging
,JULogging
,Slf4jLogging
public interface Logging
Accessor for
Logger
instances. Configured once for a driver instance using Config.ConfigBuilder.withLogging(Logging)
builder method.
Users are expected to either implement this interface or use one of the existing implementations (available via static methods in this interface):
SLF4J logging
- uses available SLF4J binding (Logback, Log4j, etc.) fails when no SLF4J implementation is available. Uses application's logging configuration from XML or other type of configuration file. This logging method is the preferred one and relies on the SLF4J implementation available in the classpath or modulepath.Java Logging API (JUL)
- usesLogger
created viaLogger.getLogger(String)
. Global java util logging configuration applies. This logging method is suitable when application uses JUL for logging and explicitly configures it.Console logging
- usesConsoleHandler
with the specifiedlogging level
to print messages toSystem.err
. This logging method is suitable for quick debugging or prototyping.No logging
- implementation that discards all logged messages. This logging method is suitable for testing to make driver produce no output.
Driver logging API defines the following log levels: ERROR, INFO, WARN, DEBUG and TRACE. They are similar to levels defined by SLF4J but different from
log levels defined for java.util.logging
. The following mapping takes place:
Driver | java.util.logging |
---|---|
ERROR | SEVERE |
INFO | INFO, CONFIG |
WARN | WARNING |
DEBUG | FINE, FINER |
TRACE | FINEST |
Example of driver configuration with SLF4J logging:
Driver driver = GraphDatabase.driver("neo4j://localhost:7687",
AuthTokens.basic("neo4j", "password"),
Config.builder().withLogging(Logging.slf4j()).build());
-
Method Summary
Modifier and TypeMethodDescriptionstatic Logging
Create logging implementation that usesjava.util.logging
to log toSystem.err
.default Logger
Obtain aLogger
instance by class, its name will be the fully qualified name of the class.Obtain aLogger
instance by name.static Logging
javaUtilLogging
(Level level) Create logging implementation that usesjava.util.logging
.static Logging
none()
Create logging implementation that discards all messages and logs nothing.static Logging
slf4j()
Create logging implementation that uses SLF4J.
-
Method Details
-
getLog
Obtain aLogger
instance by class, its name will be the fully qualified name of the class. -
getLog
Obtain aLogger
instance by name. -
slf4j
Create logging implementation that uses SLF4J.- Returns:
- new logging implementation.
- Throws:
IllegalStateException
- if SLF4J is not available.
-
javaUtilLogging
Create logging implementation that usesjava.util.logging
.- Parameters:
level
- the log level.- Returns:
- new logging implementation.
-
console
Create logging implementation that usesjava.util.logging
to log toSystem.err
.- Parameters:
level
- the log level.- Returns:
- new logging implementation.
-
none
Create logging implementation that discards all messages and logs nothing.- Returns:
- new logging implementation.
-