zoukankan      html  css  js  c++  java
  • Java Logging: Overview

     

    In this text I will try to give you an overview of the java.util.logging API. Hopefully it will be easier to understand the individual components once you understand the big picture. Many of the concepts described here are also covered in more details in subsequent texts.

    Here is an overview diagram of how the Java Logging API works:

    An overview of the core components in the Java Logging API
    An overview of the core components in the Java Logging API

    All logging is done via a Logger instance. Loggers gather the data to be logged into a LogRecord. TheLogRecord is then forwarded to a Handler. The Handler determines what to do with the LogRecord. For instance, the LogRecord can be written to disk, or sent over the network to a surveillance system.

    Both Logger's and Handler's can pass the LogRecord through a Filter which determines whether theLogRecord should be forwarded or not.

    Handler can also use a Formatter to format the LogRecord as a string before it is sent to the external disk or system.

    Log Level

    Whenever a message is logged, this message is logged with a certain log level. The level is an integer which determines how important the message is. The higher the number (level) is, the more important the message is.

    Logger can have a minimum log level set on it, which determines if the message is forwarded to a Handler or not. This is not a Filter, even though it has the same effect. For instance, all messages below a certain level can be suppressed.

    Logger Hierarchy

    The Logger instances are organized into a hierarchy. A Logger further down in the hierarchy will forward messages logged to it, to its ancestors in the hierarchy. Thus, log levels and messages can be filtered or switched on and off for entire branches of the Logger hierarchy at a time.

    LogManager

    The LogManager is a component that is not displayed in the diagram at the top of this text. The LogManagerholds the Logger hierarchy, and also a global logging configuration, which can be read from a file. TheLogManager is also covered in more detail in its own text.

  • 相关阅读:
    重磅!阿里发布《Java开发手册(泰山版)》
    IntelliJ IDEA 快捷键终极大全,速度收藏!
    Java多态的实现机制是什么,写得非常好!
    Intellij IDEA 非常 6 的 10 个姿势!
    深入浅出Java中的clone克隆方法,写得太棒了!
    Java集合类,一张图说清楚!
    在 IntelliJ IDEA 中使用 Git,太方便了!.md
    Http(get,post)及HttpClient(get,post)的简单使用
    java servlet+jquery+json学习小例子
    JAVA中使用JSON进行数据传递
  • 原文地址:https://www.cnblogs.com/hephec/p/4579557.html
Copyright © 2011-2022 走看看