Documentation
Open Source Release Policy
Export Compliance
Using BouncyCastle
Installing the API
Enabling Logging
Per-Connection Logging
Third Party Dependencies
Generating SSH Keys
Using BouncyCastle
Using SSH Public Keys in Java
Supporting ED25519/Curve25519
Supporting Compression
Integrating Licensing into Maven Builds
Creating an SSH Client
Public Key Authentication
Keyboard Interactive Authentication
Public Key Authentication with sshagent
Executing Single Commands
Executing Commands within a Shell
Transferring Files
Connecting through Proxies
Display the Authentication Banner
Using the SFTP Client
Port Forwarding
Working Examples
Configuring Listening Interfaces
Configuring Host Keys
Password Authentication
Public Key Authentication
Challenge-Response Authentication
Configuring Port Forwarding
Configuring SFTP
Supporting SCP
Implementing your own File System
Creating an Interactive Terminal
Proxy Protocol Support
How to enable logging in the Maverick Synergy Java SSH API
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);
Code language: CSS (css)
If you would prefer to log to file, you can call:
Log.getDefaultContext().enableFile(
Level.DEBUG, "synergy.log");
Code language: CSS (css)
File 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. Enter the directives described in this article below, for example, this shows how to configure console and file based logging.
# Comments allowed
maverick.log.console=true
maverick.log.console.level=DEBUG
maverick.log.file=true
maverick.log.file.level=DEBUG
maverick.log.file.path=ssh.log
Code language: PHP (php)
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.
Watching the configuration file involves a thread. If you do not want this behavior you can disable it using the maverick.log.nothread
property setting it to a value of true
. The API installs a shutdown hook to tear this thread down, however, there are circumstances where this is too late and applications like Tomcat Servlet Container can complain about memory leaks. You can alternatively force the shutdown of this thread from your own application using:
Log.shutdown();
Code language: CSS (css)
If you do not include or set up 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 |
maverick.log.nothread | false | Prevent the logging system from creating a watcher thread on logging.properties configuration file. |