java.util.logging

Basics of Handlers

In the java.util.logging package, Handlers are components that take LogRecord objects from a Logger and publish them to a specific destination (console, file, socket, etc.). Commonly Used Handlers Commonly Used Methods Simple Program: Using ConsoleHandler Output: A Handler decides where the logs go: console, file, remote socket, etc.You can attach multiple Handlers to a single …

Basics of Handlers Read More »

Exploring java.util.logging package

The java.util.logging package is Java’s built-in logging API that enables developers to capture runtime information, errors, and system status messages efficiently. Introduced in Java 1.4, it provides a standard mechanism for logging messages from Java applications. Why Use java.util.loggong? The main benefit of java.util.logging is that it is part of the Java standard library. It …

Exploring java.util.logging package Read More »

SLF4J

SLF4J (Simple Logging Facade for Java) is a Java API designed to serve as a simple facade or abstraction for various logging frameworks such as: Log4j Logback java.util.logging (JUL) Apache Commons Logging It allows developers to plug in the desired logging framework at deployment time without modifying the source code. Why Use SLF4J? Decoupling: Your …

SLF4J Read More »

Log4j

Log4j (short for Logging for Java) is a reliable, fast, and flexible logging framework developed by the Apache Software Foundation. It allows developers to log messages according to different severity levels and send those messages to multiple destinations like the console, files, GUI components, databases, or remote servers. Evolution: Log4j 1.x: Original version, now deprecated. …

Log4j Read More »

Creating loggers

Custom loggers allow you to define named loggers tailored to specific application modules, services, or classes. This modular approach helps in maintaining granular control over logging configuration, enabling separate log levels, handlers, and formatters for different components. Simple Program This shows how a custom-named logger (MyCustomLogger) is configured independently of the root logger. Problem Statement …

Creating loggers Read More »

Logging configuration through programmatically.

Java allows logging configuration directly in code. This gives developers full control over loggers, handlers, formatters, and levels at runtime, useful for dynamically adjusting logs or when file-based config isn’t practical. Simple Program Problem Statement LotusJavaPrince wants to build a logger that logs all suspicious activity to a file for compliance purposes. Mahesh, the security …

Logging configuration through programmatically. Read More »

Scroll to Top