Class JsonLogFormatter
java.lang.Object
io.github.jspinak.brobot.logging.formatter.JsonLogFormatter
- All Implemented Interfaces:
LogFormatter
JSON log formatter for machine processing.
Produces structured JSON output suitable for log aggregation systems, SIEM tools, and automated log analysis. The JSON format preserves all data types and allows for easy querying and filtering.
Output structure:
{
"@timestamp": "2023-12-01T14:23:45.123Z",
"@version": "1",
"category": "ACTIONS",
"level": "INFO",
"message": "Clicked submit button",
"thread": "main",
"correlation": {
"id": "abc123",
"session": "xyz789",
"operation": "user-login"
},
"action": {
"type": "CLICK",
"target": "submitButton",
"success": true
},
"timing": {
"duration": 25,
"startTime": "2023-12-01T14:23:45.098Z"
},
"location": {
"x": 150,
"y": 300
},
"performance": {
"memory": 1048576,
"operations": 1
},
"metadata": {
"custom": "value"
}
}
Features:
- ELK Stack compatible format
- ISO 8601 timestamps with @timestamp field
- Hierarchical structure for related fields
- Type preservation (numbers, booleans, strings)
- Complete metadata inclusion
- Error details with stack traces
- Compact JSON without pretty printing
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.github.jspinak.brobot.logging.formatter.LogFormatter
LogFormatter.FormatType
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionFormat a log entry into a string.Get the expected output format type.getName()
Get the name of this formatter for identification.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.github.jspinak.brobot.logging.formatter.LogFormatter
supports
-
Constructor Details
-
JsonLogFormatter
public JsonLogFormatter()
-
-
Method Details
-
format
Description copied from interface:LogFormatter
Format a log entry into a string.- Specified by:
format
in interfaceLogFormatter
- Parameters:
entry
- The log entry to format- Returns:
- The formatted string representation
-
getFormatType
Description copied from interface:LogFormatter
Get the expected output format type. Used for routing to appropriate output destinations.- Specified by:
getFormatType
in interfaceLogFormatter
- Returns:
- The format type
-
getName
Description copied from interface:LogFormatter
Get the name of this formatter for identification.- Specified by:
getName
in interfaceLogFormatter
- Returns:
- The formatter name
-