Additional Java SE Packages

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 »

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 »

Scroll to Top