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

📄 e389. minimizing the impact of logging code.txt

📁 这里面包含了一百多个JAVA源文件
💻 TXT
字号:
It is good to add logging code to an application, but the logging code should minimize its impact on the application, especially if the logging is not enabled. In particular, if the message to be potentially logged needs to be constructed, the method call should be wrapped in a cheaper check. For example, the method call 
    int count = 123;
    Logger logger = Logger.getLogger("com.mycompany.MyClass");
    logger.finest("count: "+count);

will cause the count to be converted to a string and then concatenated to another string. This is a lot of wasted work if the message will not be logged. To avoid this overhead, use Logger.isLoggable() to check if the message would be logged before calling the logging method. For example, 
    
    if (logger.isLoggable(Level.FINEST)) {
        logger.finest("count: "+count);
    }

⌨️ 快捷键说明

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