phase4 uses SLF4J for all logging, which means you can plug in any SLF4J-compatible backend. The example server applications ship with Apache Log4j 2.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/phax/phase4/llms.txt
Use this file to discover all available pages before exploring further.
How phase4 logging works
All phase4 loggers are created throughPhase4LoggerFactory, which wraps the standard SLF4J LoggerFactory. The wrapper adds two features:
- Thread-local prefix — a string prepended to every log message on the current thread.
- Thread-local suffix — a string appended to every log message on the current thread.
Phase4LogCustomizer and are useful for correlating log output with a specific incoming message or request.
Logger naming
All loggers follow the standard Java package name convention. The root logger for the entire library is:| Logger / package | What it covers |
|---|---|
com.helger.phase4 | All phase4 classes |
com.helger.phase4.config | Configuration loading |
com.helger.phase4.crypto | Crypto factory initialization and key loading |
com.helger.phase4.incoming | Incoming message processing |
com.helger.phase4.dump | Message dump operations |
com.helger.phase4.sender | Outgoing message sending |
org.apache.wss4j | WSS4J signing, verification, encryption, decryption |
org.apache.http | Apache HttpClient HTTP transport |
Basic log4j2 configuration
Place alog4j2.xml file on the classpath (e.g., src/main/resources/log4j2.xml):
log4j2.xml
INFO and above log events to stdout with a timestamp, level, thread name, message, and source location.
Enabling debug logging for phase4
To see detailed phase4 activity (e.g., message parsing, PMode resolution, signature operations), lower the log level for thecom.helger.phase4 package:
log4j2.xml
Enabling HTTP wire logging
To log the raw bytes of every HTTP request and response sent by the Apache HttpClient, enable debug logging for the Apache HTTP wire logger:log4j2.xml
Enabling WSS4J security debug logging
log4j2.xml
Per-thread log prefix and suffix
Phase4LogCustomizer lets you annotate log messages with a per-thread prefix or suffix. This is useful for correlating messages in multi-threaded servers:
Custom log message transformation
If you need to transform all log messages globally (not per-thread), you can extendPhase4LoggerFactory or wrap the loggers. However, the standard approach is to use the thread-local prefix/suffix mechanism above.
Complete log4j2.xml for development
The following configuration enables debug output for phase4 while keeping other libraries atINFO:
log4j2.xml