How to enable logging in the Maverick Synergy Java SSH API

Lee Painter

The Maverick Synergy Java SSH API uses an internal logging mechanism so that no logging framework is enforced upon developers using the API. This comes with the benefit that logging can easily be isolated for support purposes and then our logging does not complicate or infect your own logging output. 

The following log levels are available to you:

NONE Do not log anything
ERROR Log any errors that are caught during the API operation
WARN Potential configuration problems or harmful situations
INFO Informational messages about API operation suitable for production use
DEBUG Fine-grained information for debugging and support purposes
TRACE Even finer-grained information including binary data input/output designed for debugging and support purposes

 

You can enable logging in a number of ways. The most simple way to enable logging is to programmatically enable it from your own code. For example, to enable logging to the console call:

Log.getDefaultContext().enableConsole(Level.DEBUG);

If you would prefer to log to file, you can call:

Log.getDefaultContext().enableFile(
Level.DEBUG, "synergy.log");

 

Logging Configuration

You can control much more of the logging options by creating a logging configuration file. By default, this should be in a file called logging.properties in the current working directory of the process.

You can override the default location and file name by setting the system property:

-Dmaverick.log.config=synergy.properties

This logging configuration file is watched by the API so any changes you make to the file during runtime will cause the logging configuration to be reloaded. For example, if you experiencing problems during a running application you can enable DEBUG logs simply by editing the logging.properties file. 

If you do not include or setup logging.properties, you can set any of the following properties as System properties on your Java command line.

 

Logging Options

Option Default Value Description
maverick.log.console false Enable logging to the console
maverick.log.console.level INFO Set the level at which the console will log
maverick.log.file false Enable logging to file
maverick.log.file.level INFO Set the level for logging to file
maverick.log.file.path synergy.log The path to the log file
maverick.log.file.maxFiles 10 The maximum number of rolling log files
maverick.log.file.maxSize 20MB The maximum size of each rolling log file