🐞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
2022-10-19T15:54:29.742 FEIN SOFA (Simple OAuth 2.0 Framework for Authentication) Version 1.0.0 (2022-10-19) initialization called
2022-10-19T15:54:29.742 FEIN SOFA running on OS platform <Windows 8 6.2/amd64>
2022-10-19T15:54:29.742 FEIN SOFA running on JVM version <International Business Machines Corporation openj9-0.29.0>
2022-10-19T15:54:29.742 FEIN SOFA AES-256 cipher initialized
2022-10-19T15:54:29.742 FEIN SOFA object initialized
2022-10-19T15:54:29.742 FEIN SOFA authenticate() called
2022-10-19T15:54:29.742 FEIN OAuth authorization endpoint <https://login.microsoftonline.com/11111111-2222-3333-4444-555555555555/oauth2/v2.0/token>
2022-10-19T15:54:29.742 FEIN OAuth authorization scope <https://outlook.office365.com/.default>
2022-10-19T15:54:29.742 FEIN OAuth client ID <66666666-7777-8888-9999-111111111111>
2022-10-19T15:54:29.742 FEIN OAuth grant type <client_credentials>
2022-10-19T15:54:29.742 FEIN SOFA executeHttpTransaction() called
2022-10-19T15:54:29.742 FEIN HTTP connecting to URL <https://login.microsoftonline.com/11111111-2222-3333-4444-555555555555/oauth2/v2.0/token>
2022-10-19T15:54:29.742 FEIN HTTP method <POST>
2022-10-19T15:54:29.757 FEIN HTTP header sent <Date: Wed, 19 Oct 2022 13:54:29 GMT>
2022-10-19T15:54:29.757 FEIN HTTP header sent <User-Agent: SOFA/1.0.0 (Simple OAuth 2.0 Framework for Authentication)>
2022-10-19T15:54:29.757 FEIN HTTP header sent <Accept: application/json>
2022-10-19T15:54:29.757 FEIN HTTP header sent <Content-Type: application/x-www-form-urlencoded>
2022-10-19T15:54:29.757 FEIN HTTP header sent <Content-Length: 188>
2022-10-19T15:54:29.945 FEIN HTTP data size sent <188 bytes>
2022-10-19T15:54:29.945 FEIN HTTP connection established with cipher <TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384>
2022-10-19T15:54:30.070 FEIN HTTP header received <HTTP/1.1 200 OK>
2022-10-19T15:54:30.070 FEIN HTTP header received <x-ms-ests-server: 2.1.13943.8 - WEULR1 ProdSlices>
2022-10-19T15:54:30.070 FEIN HTTP header received <X-Content-Type-Options: nosniff>
2022-10-19T15:54:30.070 FEIN HTTP header received <Pragma: no-cache>
2022-10-19T15:54:30.070 FEIN HTTP header received <P3P: CP="DSP CUR OTPi IND OTRi ONL FIN">
2022-10-19T15:54:30.070 FEIN HTTP header received <Date: Wed, 19 Oct 2022 13:54:29 GMT>
2022-10-19T15:54:30.070 FEIN HTTP header received <Strict-Transport-Security: max-age=31536000; includeSubDomains>
2022-10-19T15:54:30.070 FEIN HTTP header received <Cache-Control: no-store, no-cache>
2022-10-19T15:54:30.070 FEIN HTTP header received <Set-Cookie: stsservicecookie=estsfd; path=/; secure; samesite=none; httponly>
2022-10-19T15:54:30.070 FEIN HTTP header received <Expires: -1>
2022-10-19T15:54:30.070 FEIN HTTP header received <Content-Length: 1595>
2022-10-19T15:54:30.070 FEIN HTTP header received <X-XSS-Protection: 0>
2022-10-19T15:54:30.070 FEIN HTTP header received <x-ms-request-id: 11111111-4444-5555-6666-777777777777>
2022-10-19T15:54:30.070 FEIN HTTP header received <Content-Type: application/json; charset=utf-8>
2022-10-19T15:54:30.070 FEIN HTTP response code <200>
2022-10-19T15:54:30.070 FEIN HTTP data size received <1595 bytes>
2022-10-19T15:54:30.070 FEIN SOFA executeHttpTransaction() elapsed time <328 ms>
2022-10-19T15:54:30.070 FEIN SOFA parseJsonResponse() called
2022-10-19T15:54:30.085 FEIN OAuth access token size received <1520> bytes
2022-10-19T15:54:30.085 FEIN OAuth returned token type <Bearer>
2022-10-19T15:54:30.085 FEIN OAuth returned access token expiration <3599> seconds
2022-10-19T15:54:30.085 FEIN OAuth access token expiration date <Wed Oct 19 16:53:29 CEST 2022>
2022-10-19T15:54:30.085 FEIN SOFA getAccessToken() called
2022-10-19T15:54:30.085 FEIN SOFA Refresh token not necessary - Returning saved OAuth 2.0 access token
Last updated