download
http://sourceforge.net/projects/log4cplus/
\log4cplus-1.2.0-rc3\msvc10
build with Visual Studo 2012
log4cplus_configure.ini
###################################
########Define log Levels##########
###################################
#All classes - except those in log4cplus.logger.* - use DEBUG level to print information on file
log4cplus.rootLogger=DEBUG, MyFileAppender
#For MemoryCheck class I need to inspect all the details, and I want print information even to the console
log4cplus.logger.MemoryCheck=TRACE, MyConsoleAppender
#For database stuff, I don't need to logging everything, it's enough printing only errors!
log4cplus.logger.DatabaseOperations=ERROR
###################################
########Define the Appenders#######
###################################
#MyConsoleAppender:
log4cplus.appender.MyConsoleAppender=log4cplus::ConsoleAppender
log4cplus.appender.MyConsoleAppender.layout=log4cplus::PatternLayout
log4cplus.appender.MyConsoleAppender.layout.ConversionPattern=[%-5p][%d] %m%n
#MyFileAppender
log4cplus.appender.MyFileAppender=log4cplus::RollingFileAppender
log4cplus.appender.MyFileAppender.File=logging.txt
log4cplus.appender.MyFileAppender.MaxFileSize=16MB
log4cplus.appender.MyFileAppender.MaxBackupIndex=1
log4cplus.appender.MyFileAppender.layout=log4cplus::PatternLayout
log4cplus.appender.MyFileAppender.layout.ConversionPattern=[%-5p][%D{%Y/%m/%d %H:%M:%S:%q}][%-l][%t] %m%n
stdafx.h
#include <log4cplus/logger.h>
#include <log4cplus/loggingmacros.h>
#include <log4cplus/configurator.h>
#include <iomanip>
using namespace log4cplus;
extern Logger g_logger;
stdafx.cpp
#include "stdafx.h"
Logger g_logger;
AppDemoDlg.cpp
BOOL CAppDemoDlg::OnInitDialog()
{
CDialog::OnInitDialog();
initialize();
PropertyConfigurator::doConfigure("log4cplus_configure.ini");
g_logger = Logger::getInstance(LOG4CPLUS_TEXT("main"));
g_logger.setLogLevel(TRACE_LOG_LEVEL);
LOG4CPLUS_INFO(g_logger, "OnInitDialog");
return TRUE;
}
댓글 없음:
댓글 쓰기