Author: gersonadr
-
The Only Guide You’ll Ever Need to Sanitise Java Logs
⏰ Reading Time: 5 minutes Ensuring data privacy in logs is crucial for compliance, security, and user trust. This guide explains how to mask and sanitise data in Java logs using Logback, Log4j, and Java Util Logging (JUL). We’ll include both configuration-based and custom code implementations, providing examples of masked log outputs and discussing best…
-
Three Ways To Reduce Your Java Logging Costs By Sampling
⏰ Reading time: 4 minutes TL;DR: Log sampling helps manage log volumes by only recording a portion of events. Use these examples to configure sampling: Why Log Sampling? Log sampling logs a subset of events to balance monitoring and performance: Configuring Log Sampling in Java 1. Logback (used by Spring Boot, version 2.x) Dependencies: Config:…
-
How to Troubleshoot SSL Handshakes in Java
⏱ Time to read: 4 minutes TL;DR SSL/TLS handshakes are vital for secure communication in Java applications. Logging and analysing handshake details helps with debugging and enhancing security. In this article, we’ll cover the most common errors during SSL/TLS handshake and how to troubleshoot them using logs. Common SSL Issues That Logging Can Help Pinpoint…
-
How To Run Java Unit Tests In VS Code: A Step-by-Step Guide
Unit testing is a crucial practice for Java developers to ensure code reliability and maintainability. Visual Studio Code (VS Code), known for its versatility, can be an effective environment for running and debugging Java unit tests. In this guide, we’ll walk through the essential steps for setting up and running Java unit tests in VS…
-
How to Output Java Logs in JSON
🕒Reading Time: 5 mins As applications grow, so does the need for structured logs that aid in debugging, fuel analytics, and provide real-time insights. JSON-based logging is perfect for those who want structured, readable logs. Here’s a quick guide to setting up JSON logging in Java with Logback, Log4j2, SLF4J, and Java Util Logging (JUL).…
-
Dude, Where Is My Log File? A Step-by-Step Troubleshooting Guide
🕒 Reading Time: 7 minutes Logs are essential in Java for tracking and troubleshooting issues. But when you’re new to a project, especially one running in Docker or on a server, finding the log files can feel like searching for a needle in a haystack. This guide covers how to locate Java log files across…
-
How to Generate and Interpret GC Logs
⏱ Time to Read: 9 minutes TL;DR If you’re diving into Java performance optimization, understanding and analyzing Garbage Collection (GC) logs is essential. GC logs provide insights into memory management and help identify bottlenecks in your application. This guide walks you through generating GC logs in Java, understanding the parameters, and analyzing the output to…
-
Measuring Elapsed Time in Java
🕒 Reading time: 7 minutes TL;DR Sample Code to Measure We’ll measure the time taken by this sample method, sumArray, to sum elements in a large array: 1. Using System.currentTimeMillis() This basic method returns the current time in milliseconds since the Unix epoch. Simple but limited. When to Use It When Not to Use It…
-
Changing Logging Configuration via Command Line in Java + Bonus
(5 minutes read) When it comes to managing logs in Java applications, having flexibility in how logging is configured is key. Whether you’re debugging an application or want to increase logging verbosity in production, adjusting the logging configuration from the command line can be a lifesaver. This article explores how to modify logging settings on…
-
8 Ways to Log Stack Traces in Java
Logging in Java is essential for understanding your application’s behavior, especially during errors. While simple messages might work for minor issues, stack traces provide the deeper context needed for effective troubleshooting. This guide explores best practices for logging stack traces using various Java logging libraries, explains how to format logs correctly, and demonstrates logging custom…