热门面试题与答案和在线测试
面向面试准备、在线测试、教程与实战练习的学习平台

通过聚焦学习路径、模拟测试和面试实战内容持续提升技能。

WithoutBook 将分主题面试题、在线练习测试、教程和对比指南整合到一个响应式学习空间中。

Chapter 8

Filtering, Routing, Markers, and Fine-Grained Logging Control

Move beyond basic levels and learn how Log4j controls which events flow to which destinations.

Inside this chapter

  1. Why Levels Alone Are Not Always Enough
  2. Filters
  3. Markers
  4. Routing as an Operational Tool

Series navigation

Study the chapters in order for the clearest path from beginner logging concepts to advanced operational logging design. Use the navigation at the bottom of each page to move through the full series.

Tutorial Home

Chapter 8

Why Levels Alone Are Not Always Enough

In real applications, teams sometimes need more than simple INFO versus ERROR control. They may want certain audit events routed separately, some packages muted, or only specific categories forwarded to a destination.

Chapter 8

Filters

Filters allow Log4j to accept, deny, or neutralize events based on conditions such as level, marker, message content, or logger source. They help refine log flow without changing application code everywhere.

Chapter 8

Markers

import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.MarkerManager;

private static final Marker AUDIT = MarkerManager.getMarker("AUDIT");
logger.info(AUDIT, "User role updated");

Markers let teams tag special log events semantically, such as audit, security, billing, or business workflow logs.

Chapter 8

Routing as an Operational Tool

Advanced systems often send different log categories to different appenders or downstream platforms. That is one of the ways teams keep logs useful without drowning all outputs in the same noise.

版权所有 © 2026,WithoutBook。