Last active
February 15, 2022 15:20
-
-
Save zachelrath/f6cd37768dd959b78ace8507f01f4f44 to your computer and use it in GitHub Desktop.
Structured data logging with Log4j ObjectMessage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Data | |
@AllArgsConstructor | |
@NoArgsConstructor | |
public class ItemLog { | |
private Integer totalItems; | |
private List<OrderItem> items; | |
public ItemLog(List<OrderItem> items) { | |
this.items = items; | |
this.totalItems = items.size(); | |
} | |
} | |
logger.info(new ObjectMessage(new ItemLog(orderItems)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment