log.file is configured. Both the verbosity and the destination are controlled through the configuration file.
Log levels
Thelog.level option sets the minimum severity required for a message to be emitted. Messages below the configured level are silently discarded.
| Level | Syslog priority | When to use |
|---|---|---|
ERROR | LOG_ERR | Production deployments (default). Only genuine errors are logged. |
WARNING | LOG_WARNING | Captures non-fatal conditions such as missing optional config keys. |
INFO | LOG_INFO | Logs notable events — token initialisation, session open/close, and so on. |
DEBUG | LOG_DEBUG | Full internal tracing. Generates a high volume of output; use only when diagnosing a specific problem. |
Changing the log level
The log level can only be changed by editing the configuration file. There is no signal or API to adjust it at runtime without reloading. Because SoftHSM is a shared library loaded in-process by an application, the configuration is re-read only when the application initialises the PKCS#11 library (callsC_Initialize).
To increase verbosity for a running application you must:
- Stop the application.
- Edit
log.levelin the configuration file. - Restart the application.
Log destinations
syslog (Linux and macOS)
By default, all log messages are sent to syslog using the standardsyslog(3) facility. Messages appear in the system journal or /var/log/syslog depending on the syslog daemon configuration.
To view SoftHSM messages from the system journal:
Windows Event Log
On Windows, messages are written to the Windows Event Log through the same syslog-compatible interface.Log file
To redirect log output from syslog to a file, setlog.file:
There is no built-in log rotation. If you use
log.file, configure an external log rotation tool (such as logrotate) to manage file growth.Log message format
Every log message is prepended with the source file name and line number from the SoftHSM source code where the message originated. This is always enabled and cannot be disabled at runtime. When logging to syslog:Common log messages
Configuration warning on startup
Token directory not found
directories.tokendir does not exist or is not readable. Create the directory before loading the library:
Missing configuration key
WARNING-level message and only appears when log.level is WARNING or more verbose.