c++ log4cxx自定义日志存放目录
来源:互联网 发布:淘宝换货不需要申请吗 编辑:程序博客网 时间:2024/06/06 09:02
#include <log4cxx/logger.h>#include <log4cxx/helpers/pool.h>#include <log4cxx/basicconfigurator.h>#include <log4cxx/fileappender.h>#include <log4cxx/simplelayout.h>#include <log4cxx/propertyconfigurator.h>#include<log4cxx/patternlayout.h>#include<log4cxx/dailyrollingfileappender.h>#pragma comment(lib,"log4cxx.lib")InitLog(){ string conversionPattern = "[%d %M]: %m%n";log4cxx::PatternLayoutPtr layout = new PatternLayout();int len = MultiByteToWideChar(CP_ACP, 0, conversionPattern.c_str(), -1, NULL, 0);wchar_t *pStr = new wchar_t[(len + 1) * sizeof(wchar_t)];MultiByteToWideChar(CP_ACP, 0, conversionPattern.c_str(), -1, pStr, len);layout->setConversionPattern(pStr);delete[]pStr;pStr = nullptr;// creates daily rolling file appenderDailyRollingFileAppenderPtr rollingAppenderptr = new DailyRollingFileAppender();char svc_path[256] = { 0 };GetModuleFileNameA(NULL, svc_path, sizeof(svc_path));std::string str_svc_path = svc_path;std::string file_name = str_svc_path.substr(str_svc_path.find_last_of("\\/") + 1, 50);std::string file_path = str_svc_path.substr(0, str_svc_path.find_last_of("\\/") + 1);std::string Property = file_path + "Log\\Report.log";len = MultiByteToWideChar(CP_ACP, 0, Property.c_str(), -1, NULL, 0);pStr = new wchar_t[(len + 1) * sizeof(wchar_t)];MultiByteToWideChar(CP_ACP, 0, Property.c_str(), -1, pStr, len);rollingAppenderptr->setFile(pStr);delete[]pStr;pStr = nullptr;rollingAppenderptr->setDatePattern(_T("'.'yyyy-MM-dd"));rollingAppenderptr->setLayout(layout);log4cxx::helpers::Pool p;rollingAppenderptr->activateOptions(p);// configures the root loggerlog4cxx::LoggerPtr g_log_ptr = log4cxx::Logger::getRootLogger();g_log_ptr->setLevel(log4cxx::Level::getDebug());g_log_ptr->addAppender(rollingAppenderptr);}
阅读全文
0 0
- c++ log4cxx自定义日志存放目录
- Hadoop日志存放目录
- 自定义log4j日志文件存放路径
- 自定义redmine的附件存放目录
- log4cxx日志记录
- 日志操作利器log4cxx
- log4cxx日志工程引用
- Zookeeper自定义日志目录
- Nginx 自定义日志目录
- Log4j日志文件存放到项目目录下
- 【C++】log4cxx相关使用
- 日志操作利器log4cxx 分享
- 日志操作利器log4cxx 分享
- 日志操作利器log4cxx 分享
- 多进程log4cxx区分日志
- 日志操作利器log4cxx 分享
- 日志操作利器log4cxx 分享
- ZooKeeper自定义数据日志目录
- Python 列表推导
- Robot Framework如何判断Android屏幕是否含有某个控件
- AWS EC2 shadowsocks服务端搭建
- 主元素
- 开发者需要知道的十几个网站
- c++ log4cxx自定义日志存放目录
- Java中String字符串转整型或浮点型
- Java入门记(一):折腾HelloWorld
- 97.二叉树的最大深度
- 为什么这么多事??!!!!
- AngualrJs 最新 文件图片上传教程0:Client-module
- C语言集成开发环境vs2017的使用技巧之修改快捷键
- Linux(1)--各个发行版本对比与简介
- date