To enable the logs, simply set the environment variable HSM_LOG_LEVEL with one of the values below:

1 - INFO
2 - WARNING
3 - ERROR

Setting the environment variable via the terminal

export HSM_LOG_LEVEL=1

Setting the environment variable via javascript

process.env.HSM_LOG_LEVEL = "1"; // INFO

To direct the logs to a file, simply set the environment variable HSM_LOG_DIR with the path of the folder where the file will be created.
If this variable is not set, the logs will be directed to the console.

Setting the environment variable via the terminal

export HSM_LOG_DIR=/var/logs/hsm_logs

Setting the environment variable via javascript

process.env.HSM_LOG_DIR = "/var/logs/hsm_logs";