Chinaunix首页 | 论坛 | 博客
  • 博客访问: 70124
  • 博文数量: 24
  • 博客积分: 81
  • 博客等级: 民兵
  • 技术积分: 136
  • 用 户 组: 普通用户
  • 注册时间: 2011-12-08 00:56
文章分类
文章存档

2012年(9)

2011年(15)

我的朋友

分类:

2011-12-12 23:46:34

原文地址:poco c++ 日志级别设置 作者:fangp

poco c++ 日志级别设置
 
问题:因之前日志(taskrunner.properties)级别为debug,会输出很多程序运行的细节信息日志,占用了很多系统资源,于是一同事将debug改成info,这一改导致所有相关程序都调不起来!
检查:
1、Logger.cpp 程序,片断
 
void Logger::setLevel(const std::string& level)
{
        if (level == "fatal")
                setLevel(Message::PRIO_FATAL);
        else if (level == "critical")
                setLevel(Message::PRIO_CRITICAL);
        else if (level == "error")
                setLevel(Message::PRIO_ERROR);
        else if (level == "warning")
                setLevel(Message::PRIO_WARNING);
        else if (level == "notice")
                setLevel(Message::PRIO_NOTICE);
        else if (level == "information")
                setLevel(Message::PRIO_INFORMATION);
        else if (level == "debug")
                setLevel(Message::PRIO_DEBUG);
        else if (level == "trace")
                setLevel(Message::PRIO_TRACE);
        else
                throw InvalidArgumentException("Not a valid log level", level);
}
 
2、Message.h 程序,片断
        enum Priority
        {
                PRIO_FATAL = 1,   /// A fatal error. The application will most likely terminate. This is the highest priority.
                PRIO_CRITICAL,    /// A critical error. The application might not be able to continue running successfully.
                PRIO_ERROR,       /// An error. An operation did not complete successfully, but the application as a whole is not affected.
                PRIO_WARNING,     /// A warning. An operation completed with an unexpected result.
                PRIO_NOTICE,      /// A notice, which is an information with just a higher priority.
                PRIO_INFORMATION, /// An informational message, usually denoting the successful completion of an operation.
                PRIO_DEBUG,       /// A debugging message.
                PRIO_TRACE        /// A tracing message. This is the lowest priority.
        };
 
处理:将属性配置文件(taskrunner.properties) 相应语句设置如下:
logging.loggers.app.level =information
 
重调相关程序,都OK了!
 
 
阅读(1115) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~