java.util.logging

Logging configuration through properties files

Java provides the ability to configure the logging behavior externally through .properties files, removing the need to hardcode logger behavior into the Java source code. This enables dynamic control over: Logger levels Handler types and destinations Formatter styles Output files, consoles, or network sockets Format of Logging Properties File Java logging reads configuration from a …

Logging configuration through properties files Read More »

Level

The Level class in the java.util.logging package defines a set of standard logging levels that indicate the severity of log messages. Loggers and handlers use these levels to decide what messages to log or ignore. Commonly Used Methods Standard Logging Levels Simple Program Using Levels Problem Statement: LotusJavaPrince has built a Banking Alert System. Mahesh, …

Level Read More »

Filter

The Filter interface is part of the java.util.logging package and is used to control whether a particular LogRecord should be logged or discarded. Filters can be applied to Logger or Handler objects to fine-tune the logging output. Commonly Used Methods Simple Program  This program logs only messages with level WARNING or above. Problem Statement LotusJavaPrince …

Filter Read More »

XMLFormatter

XMLFormatter is a class (commonly from java.util.logging) used to format logging records into XML format. It transforms log entries into a structured XML string. It can also refer to a custom utility class to format any raw XML string into a human-readable, pretty-printed XML format with indentation. Commonly Used Methods Simple Program Problem Statement: LotusJavaPrince …

XMLFormatter Read More »

SimpleFormatter

SimpleFormatter is a built-in formatter class in Java used to format log records into a simple, readable, text-based format. Simple Program Sample Output: Problem Statement LotusJavaPrince is building a Banking Transaction Logger. Mahesh, the lead developer, wants to log all deposit and withdrawal activities with a simple timestamped format for debugging and audit tracking. The …

SimpleFormatter Read More »

Formatter

The Formatter class in java.util.logging is used to control the output format of log messages. When a Logger sends a log record to a Handler, the handler uses a Formatter to convert the LogRecord into a human-readable string. Common Subclasses of Formatter Commomly Used Methods Simple Example with Built-in Formatters Output in simple_log.log: Problem Statement: …

Formatter Read More »

Basics of Formatters

In the Java Logging API (java.util.logging), a Formatter is used to convert a LogRecord into a human-readable string. Formatters decide how log messages appear—e.g., timestamped lines, JSON, XML, or custom formats. Formatters are essential when logs need to be stored, shared, or visualized clearly. Customize log output format Apply consistent structure across handlers (e.g., console, …

Basics of Formatters Read More »

StreamHandler

StreamHandler is a handler in Java’s logging API that writes log records to a given OutputStream. It is useful when you want to log messages to: A custom stream like ByteArrayOutputStream A Socket stream Any generic OutputStream (e.g., file, memory, network) However, it does not flush automatically, so you must call flush() or close() to …

StreamHandler Read More »

SocketHandler

SocketHandler is a logging handler in the java.util.logging package that sends log messages to a remote logging server using TCP sockets. This is useful for: Distributed systems Centralized logging Real-time monitoring It requires a logging server to receive and process logs (typically using SocketHandler + SocketHandlerServer or a custom SocketHandlerListener). Commonly Used Methods Simple Program …

SocketHandler Read More »

Scroll to Top