⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e390. preventing a logger from forwarding log records to its parent.txt

📁 这里面包含了一百多个JAVA源文件
💻 TXT
字号:
By default, a logger sends a log record not only to its handlers but to all the handlers of ancestor loggers. If the effects of the parent handlers are not desired, it is necessary to prevent log records from being forwarded to the parent. 
This example demonstrates how to stop a logger from sending log records to its parent. 

Note: Although the level of a log record is tested against the logger's log level, this test is not done with any of the logger's parents. However, the log level of all handlers is still in effect. 

    // Get a logger
    Logger logger = Logger.getLogger("com.mycompany");
    
    // Stop forwarding log records to ancestor handlers
    logger.setUseParentHandlers(false);
    
    // Start forwarding log records to ancestor handlers
    logger.setUseParentHandlers(true);

 Related Examples 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -