The library logs additional information on Level.FINE.
Among the log information that the library outputs you can find: algorithms used for given operation, list of encryption key Id’s for a file being decrypted, etc.
In order the logging to be enabled it has to be configured for the library package, because the standard Java logging is set to Level.INFO.
Logging in a Console application
For example to configure the library logging for a console application we have to pass a JVM argument that specifies the location of a log properties file:
Logging in an Application Server
If your application is a web application you have to set the log properties in the log configuration file of the application server. Please refer to the documentation for log configuration of your application server.
Example log configuration file
Here is an example log.properties file that enables logging for the classes that reside in the com.didisoft.pgp package:
# Specify the handlers to create in the root logger # (all loggers are children of the root logger) # The following creates two handlers handlers = java.util.logging.ConsoleHandler, java.util.logging.FileHandler # Set the default logging level for the root logger .level = WARNING # Set the default logging level for new ConsoleHandler instances java.util.logging.ConsoleHandler.level = ALL # Set the default formatter for new ConsoleHandler instances java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter # Set the default logging level for the logger named com.didisoft.pgp java.util.logging.FileHandler.level = ALL java.util.logging.FileHandler.filter = java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter java.util.logging.FileHandler.encoding = java.util.logging.FileHandler.limit = java.util.logging.FileHandler.count = java.util.logging.FileHandler.append = true java.util.logging.FileHandler.pattern = log.txt com.didisoft.pgp.level = ALL
The above example log configuration will output the library log messages in a file called log.txt located in the current working directory.
This short article described how to enable java logging for DidiSoft OpenPGP Library for Java.
The full configuration of the java logging framework is beyond the scope of this chapter and we encourage you to have a look at it.