Without log rotation, a long-running Java application will eventually fill your disk with a single ever-growing log file. Logback’s RollingFileAppender solves this by automatically creating a new log file when a threshold is crossed and optionally compressing or deleting old files. In this guide you will learn every rolling policy Logback provides, understand each configuration attribute, and walk away with production-ready logback.xml examples you can drop into your Spring Boot or plain Java application today.
Category Archives: Java
Masking Sensitive Data in Logback: A Complete Developer Guide
Logging is indispensable for debugging and observability — but logs that accidentally capture credit card numbers, passwords, or Social Security Numbers can turn a routine audit into a data-breach incident. In this guide you will learn three practical techniques for masking sensitive data in Logback: a zero-code XML replacement rule, a lightweight custom MessageConverter, and a full PatternLayout override. Every approach comes with working code, a comparison table, and production-hardening tips.
Implementing Vector Embeddings and Semantic Search in Pure Java
Every modern AI search system — from Google to ChatGPT’s retrieval pipeline — works by converting text into numerical vectors and measuring how close those vectors are in high-dimensional space. This technique is called semantic search, and the numerical representations are called vector embeddings. Despite being the backbone of Retrieval-Augmented Generation (RAG), recommendation engines, and intelligent search, virtually every tutorial on the internet implements it in Python. Java developers are left guessing.
This post builds a complete semantic search engine in pure Java — no LangChain4j, no Spring AI, no external dependencies. We implement TF-IDF vectorisation, cosine similarity, and a query engine that ranks documents by meaning rather than keyword matching. By the end, you will understand the exact mathematics that powers every vector database on the market.
Continue reading Implementing Vector Embeddings and Semantic Search in Pure JavaBuilding a Neural Network from Scratch in Pure Java (No Libraries)
Neural networks power everything from image recognition to language models, yet most tutorials use Python and hide the mathematics behind library calls. If you are a Java developer, building a neural network from raw arithmetic — no TensorFlow, no DL4J, no dependencies at all — is the single best way to internalise how learning actually works at the weight-and-gradient level.
This post implements a fully connected, multi-layer feedforward neural network in pure Java. The network learns the XOR function, a classic problem that a single-layer perceptron cannot solve, which is exactly why it is the standard benchmark for testing that backpropagation is implemented correctly. Every line is annotated with the mathematics driving it.
Continue reading Building a Neural Network from Scratch in Pure Java (No Libraries)Building a REST API with Spring Boot: Complete Beginner's Guide
Spring Boot strips away the configuration ceremony that used to make Spring applications time-consuming to set up. You add a dependency, annotate a class, and a production-grade REST endpoint is running in seconds. This guide builds a complete, working REST API from a blank project to a tested, structured service – explaining every decision along the way.
By the end you will have a runnable Spring Boot application with GET, POST, PUT, and DELETE endpoints, proper HTTP status codes, global exception handling, validation, and a structure that scales to a real project.
Continue reading Building a REST API with Spring Boot: Complete Beginner's GuideJava Collections Framework: Choosing the Right Data Structure
Java ships with a rich library of data structures under the java.util package. The problem is not finding a collection u2014 it is picking the right one. Using an ArrayList when you need fast membership checks, or a HashMap when you need sorted keys, is the kind of mismatch that shows up in code reviews and performance profiles.
This guide maps every important class to the use case it is designed for, explains the time complexity of its key operations, and provides working code you can copy directly into a project. By the end you will have an intuition for which collection to reach for in any situation.
Continue reading Java Collections Framework: Choosing the Right Data StructureJava Streams API: The Complete Reference Guide
The Streams API, introduced in Java 8, fundamentally changed how Java developers process collections. Instead of writing loops that describe how to iterate, you write pipelines that describe what to compute. The result is code that is shorter, easier to parallelise, and far more composable than the equivalent imperative loop.
This guide is designed as a reference you will return to. Every method in the API is covered with a working example and annotated output. The final sections address collectors in depth, parallel streams, and the mistakes that trip up developers who are new to the functional style.
Continue reading Java Streams API: The Complete Reference Guide