🐞Logging / Debugging

The SOFA Java class has a builtin, detailed logging funtion to help finding and diagnosing any issue you may encounter.

To enable the Java Logger framework, you need to add a Logger properties file SOFA-Logging.properties in the current directory of your running application.

SOFA-Logging.properties Example

# SOFA - Simple OAuth 2.0 Framework for Authentication - Logging configuration file
#
# Notes:
# - The SOFA class only uses logging level FINE (for debugging) and WARNING (for errors)
# - To disable logging, comment out all "handlers" properties or remove/rename this configuration file)

# Logging level for the SOFA class
SOFA.level                                  = FINE

# Specify where the logging output should go
#handlers                                   = java.util.logging.ConsoleHandler
#handlers                                   = java.util.logging.FileHandler
handlers	                            = java.util.logging.ConsoleHandler, java.util.logging.FileHandler

# Logging output format, e.g. "2022-01-27T16:44:00.322 FINE        SOFA Version ..."
java.util.logging.SimpleFormatter.format    = %1$tFT%1$tT.%1$tL %4$-11s %5$s %6$s %n

# Define logging output to system console
java.util.logging.ConsoleHandler.level      = ALL
java.util.logging.ConsoleHandler.formatter  = java.util.logging.SimpleFormatter

# Define logging output to file (maximum 10 files, each up to about 60 kB)
java.util.logging.FileHandler.pattern       = ALL
java.util.logging.FileHandler.formatter     = java.util.logging.SimpleFormatter
java.util.logging.FileHandler.pattern       = SOFA-Log-%g.txt
java.util.logging.FileHandler.count         = 10
java.util.logging.FileHandler.limit         = 60000
java.util.logging.FileHandler.append        = true

This Logger configuration file writes the logging output to System.out and to the files SOFA-Log-0.txt to SOFA-Log-9.txt.

Output Example

Last updated