Logging capability is available in the Java® client to record details such as HTTP request statuses, server URLs, and
output data. Logging is implemented using the slf4j, so it can work
with multiple logging engines, such as log4j,
logback, or java.util.logging.
It can utilize the logging engine used in your project, from one of the
slf4j supported engines, or load its own embedded engine if none
is provided.

log4j EngineWhen your project does not use a logging engine, and you want to log just the
Java client activity, you can activate the Java client embedded log4j engine it can use once
activated. To use the embedded engine, pass in a log4j
configuration file to the Java application at startup. To do this, add the file location URL to the
log4j.configuration JVM property. The URL to a file on the
file system is:
file:/path/to/file/filename
The embedded engine is loaded only if no engine is provided.
The default log4j configuration file that outputs to standard
out is found at the following location:
$MPS_INSTALL/client/java/log4j.properties.
Example (UNIX® syntax):
java -cp ./mps_client.jar:./Magic.jar -Dlog4j.configuration=file:/$MPS_INSTALL/client/java/log4j.properties Magic
If your project uses an existing engine, the Java client can use that engine for logging. Your project can use any
engine that supports slf4j. To use an existing engine, you must
be able to load it into your Java application, and it must be on your Java classpath. If you need
different version of the slf4j engine, you can load your own
slf4j library and include it in your classpath.
For java.util.logging, you need to load and use the
java.util.logging.Logger class in your Java application code before the
com.mathworks.mps.client.MWHttpClient class is loaded.
For logback, add both the logback-classic and
logback-core jar files onto the classpath.
If you encounter version mismatch issues between your engine and
slf4j, it is best to load your own
slf4j-api.jar of the appropriate version by setting it on the
Java classpath. This situation can occur if you are using later versions of
logback.
Example (UNIX syntax):
#Using existing log4j engine java -cp ./log4j.jar:./mps_client.jar:./MyApplication.jar -Dlog4j.configuration=file:/path/to/log4j.properties MainClass #Using existing logback engine java -cp ./logback-classic.jar:./logback-core.jar:./mps_client.jar:./MyApplication.jar -Dlogback.configurationFile=/path/to/config.xml MainClass #Using existing slf4j API java -cp ./slf4j-api.jar:./mps_client.jar:./MyApplication.jar MainClass #Using existing logback engine with existing slf4j java -cp ./slf4j-api.jar:./logback-classic.jar:./logback-core.jar:./mps_client.jar:./MyApplication.jar -Dlogback.configurationFile=/path/to/config.xml MainClass
Refer to the third-party logging engine documentation for more information on how to configure the logging behavior.
Note
If loading existing slf4j or logback
jars, it must be set in front of the mps_client.jar on
the Java classpath.