The configuration on the client side requires the integration of the
jar
files from the /client-lib
directory into the class path of the application and development environment.
See Chapter 6, Application / Functionality for the use of the client libraries and according code examples.
jadice server's code base often uses logging to draw attention to problems and facilitate traceability. There are several commonly available frameworks for the use of logging, which follow different approaches and come with different ranges of functions.
Since the jadice server client API is designed for integration into a complete application, it is not bound to a specific logging framework. Instead, we provide the jadice Logging Framework Façade, which can connect to the logging system of the integrating application.
jadice Logging Framework Façade allows for a direct and simple integration of the most common logging systems and frameworks, for example JDK Logging, Log4J, SLF4J and via SLF4J Logback, JCL, x4Juli and many others. If you are using one of these frameworks, often a modification to the class path suffices to enable the output of log messages in this framework.
If no particular logging delegate, i. e. a particular logging framework, is defined by the class path, JDK logger, which is contained in Java, will be used as a fallback. Since the JDK logger is always available as fallback, it does not matter when the desired target logging system is defined in the class path. Furthermore, different logging systems can be used in the developing phase and in the eventual productive system. Through the use of the logging façade even a later change of the logging system is feasible without further programming effort.
The following paragraphs first explain the use of the logging façade with different target logging frameworks.
Beside the default JDK logger, the distribution of jadice server provides two further implementations of logging delegates. If Log4J is used, just add the corresponding Log4J implementation to the application’s class path. To employ a different logging framework, use the corresponding SLF4J implementation in the class path instead.
The following paragraphs describe the location of the desired implementation of the logging delegates in the distribution and elucidate which further steps are necessary to employ it.
The logging delegates contained in the distribution do not need further configuration. An customization of the target logging system’s behavior, e. g. of the log level, is generally managed by the configuration possibilities of the respective target logging system.
The implementation of the logging delegate for Log4J corresponds to the following naming convention:
logging-log4j-
version
.jar
You can find the Log4J delegate which matches the jadice server client API modules
in use in the following directory in the distribution:
client-lib/logging
.
Please insert the Log4J delegate matching your jadice server version as well as Log4J itself into the application’s class path. If a log4J configuration is already available on the class path, no further configuration is required.
Log4J as well as detailed information on the configuration of Log4J can be found on the Log4J homepage and in the Log4J manual.
The naming convention of SLF4J’s logging delegate follows this pattern:
logging-slf4j-
version
.jar
Similar to Log4J you will find the SLF4J delegate which matches
the corresponding client API modules in use in the following directory:
client-lib/logging
.
Please insert the SLF4J delegate matching your jadice server version into the
classpath of the application. slf4j-api-
and a logging implementation are also required. See the SLF4J
homepage and the SLF4J manual for
detailed information about SLF4J and supported types of the logging delegates and implementations..
version
.jar
Most of the classes of jadice server client API generate logging output. If one of these
classes is activated – i. e. loaded by the ClassLoader
–
it requests a logger from the jadice logging framework. With the first request, the framework
is initialised and searches the class path for the desired target logging system.
If this search fails, the following message is displayed on the command line:
Unable to initialize logging.
Another message then provides details about the cause for the failed search. There are two types of causes:
-
No logging delegation implementation on classpath
If this error message appears, neither of the two logging delegates for Log4J or SLF4J described in the previous paragraphs have been found in the class path. The
.jar
file for the desired target logging system thus has to be properly added to the Java class path, as described in the preceding paragraphs. -
Initialization failure due to exception
This error message indicates a problem in the underlying target logging system and thus may have multiple reasons. Generally, the documentation of the respective system should be consulted.
The following examples illustrate specific errors.
Example 5.1. Missing Log4J Library
Unable to initialize logging. Initialization failure due to exception: java.lang.NoClassDefFoundError: org/apache/log4j/LogManager at com.levigo.util.log.impl.Log4JLogFactory.<clinit>(Log4JLogFactory.java:23) at com.levigo.util.log.impl.LoggingBinder.getLoggerFactory(LoggingBinder.java:17) at com.levigo.util.log.LoggerFactory.<clinit>(LoggerFactory.java:24) ... (some more omitted entries) No logging binder available. Using JDK logging instead.
In this case it is likely that the Log4J library is not provided in the class path. To solve this problem the corresponding
.jar
file has to be added to the application’s class path and you should make sure that the file can be accessed.Example 5.2. Missing SLF4J Library
The following error message refers to the same problem and is provoked by a required but missing SLF4J library. To solve the problem the corresponding
.jar
file must be added to the application’s class path and access to it should be ensured.Unable to initialize logging. Initialization failure due to exception: java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory at com.levigo.util.log.impl.Slf4JLogFactory.<clinit>(Slf4JLogFactory.java:17) at com.levigo.util.log.impl.LoggingBinder.getLoggerFactory(LoggingBinder.java:17) at com.levigo.util.log.LoggerFactory.<clinit>(LoggerFactory.java:24) ... (some more omitted entries) No logging binder available. Using JDK logging instead.
Example 5.3. Missing Delegate for SLF4J
Since SLF4J constitutes a logging façade, the following error may appear.
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. Unable to initialize logging. Initialization failure due to exception: java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder at org.slf4j.LoggerFactory.<clinit>(LoggerFactory.java:60) at com.levigo.util.log.impl.Slf4JLogFactory.<clinit>(Slf4JLogFactory.java:17) at com.levigo.util.log.impl.LoggingBinder.getLoggerFactory(LoggingBinder.java:17) at com.levigo.util.log.LoggerFactory.<clinit>(LoggerFactory.java:24) at com.levigo.jadice.gui.AbstractJadicePanel.<clinit>(AbstractJadicePanel.java:42) ... (some more omitted entries) No logging binder available. Using JDK logging instead.
See the documentation of SLF4J for information on how to eliminate this error.