本文整理汇总了C++中Appender::setLayout方法的典型用法代码示例。如果您正苦于以下问题:C++ Appender::setLayout方法的具体用法?C++ Appender::setLayout怎么用?C++ Appender::setLayout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Appender
的用法示例。
在下文中一共展示了Appender::setLayout方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AppLogFile
int CommInpCfg :: redirectLog ()
{
time_t curr_t;
struct tm *ptm;
char log_file_name[32];
time (&curr_t);
ptm = gmtime (&curr_t);
strftime (log_file_name, 32, "%Y%m%d_%H%M%S.log", ptm);
string AppLogFile(dataOpt__.WorkingPath);
AppLogFile.append("/")
.append(log_file_name);
Category& rootLogCategory = Category::getRoot();
rootLogCategory.removeAllAppenders();
Appender* appender = new FileAppender("Log", AppLogFile);
PatternLayout* patternLayout = new PatternLayout();
patternLayout->setConversionPattern("[%d{%Y:%m:%d %H:%M:%S.%I}] %p %c %x: %m%n");
Layout* layout = dynamic_cast<Layout*> (patternLayout);
appender->setLayout(layout);
cout << "Redirecting logging from stdout to : " << AppLogFile << endl;
rootLogCategory.addAppender(appender);
return 0;
}
示例2: init
void HttpLog::init()
{
s_pLogger = Logger::getRootLogger() ;
new(achAccessLog) AccessLog("");
Appender *appender
= Appender::getAppender("stderr", "appender.ps");
Layout *layout = Layout::getLayout(ERROR_LOG_PATTERN, "layout.pattern");
layout->setUData(s_logPattern);
appender->setLayout(layout);
logger()->setLevel(Level::DEBUG);
logger()->setAppender(appender);
}
示例3: CommInpCfg
CommInpCfg :: CommInpCfg()
{
// Set up logging with stdout as destination
Category& rootLogCategory = Category::getRoot();
rootLogCategory.setPriority(Priority::INFO);
rootLogCategory.removeAllAppenders();
Appender* appender = new FileAppender("_", dup(fileno(stdout)));
PatternLayout* patternLayout = new PatternLayout();
patternLayout->setConversionPattern("[%d{%Y:%m:%d %H:%M:%S.%I}] %p %c %x: %m%n");
Layout* layout = dynamic_cast<Layout*> (patternLayout);
appender->setLayout(layout);
rootLogCategory.addAppender(appender);
}
示例4: initLogger
static log4cxx::Logger* initLogger(const char* logFile, const char* logLevel)
{
static char s_parttern[] = "%d [%p] [%c] %m";
using namespace LOG4CXX_NS;
Logger *pLogger = Logger::getRootLogger() ;
Appender * appender
= Appender::getAppender( logFile, "appender.ps" );
Layout* layout = Layout::getLayout( "patternErrLog", "layout.pattern" );
layout->setUData( s_parttern );
appender->setLayout( layout );
log4cxx::Level::setDefaultLevel(Level::toInt(logLevel));
pLogger->setLevel( logLevel );
pLogger->setAppender( appender );
return pLogger;
}
示例5: setErrorLogFile
int HttpLog::setErrorLogFile(const char *pFileName)
{
Appender *appender
= Appender::getAppender(pFileName, "appender.ps");
if (appender)
{
Appender *pOld = logger()->getAppender();
if ((pOld) && (pOld != appender))
pOld->close();
Layout *layout = Layout::getLayout(ERROR_LOG_PATTERN, "layout.pattern");
appender->setLayout(layout);
logger()->setAppender(appender);
return 0;
}
else
return LS_FAIL;
}
示例6: initialize_log
void initialize_log(const char* name, int verbose, string const& file_log = "")
{
// 1 instantiate an appender object that
// will append to a log file
Appender* app;
if (file_log.empty())
app = new OstreamAppender(name, &std::cout);
else
app = new FileAppender(name, file_log);
// 2. Instantiate a layout object
// Two layouts come already available in log4cpp
// unless you create your own.
// BasicLayout includes a time stamp
Layout* layout = new BasicLayout();
// 3. attach the layout object to the
// appender object
app->setLayout(layout);
// 4. Instantiate the category object
// you may extract the root category, but it is
// usually more practical to directly instance
// a child category
Category * main_cat = &Category::getInstance(name);
// 5. Step 1
// an Appender when added to a category becomes
// an additional output destination unless
// Additivity is set to false when it is false,
// the appender added to the category replaces
// all previously existing appenders
main_cat->setAdditivity(false);
// 5. Step 2
// this appender becomes the only one
main_cat->setAppender(app);
// 6. Set up the priority for the category
// and is given INFO priority
// attempts to log DEBUG messages will fail
main_cat->setPriority( verbose*100 );
}
示例7: lock
Appender * Appender::getAppender(com_device_t &dev)
{
xAutoLock lock(&comlog_appender_getlock);
//devµÄ²ÎÊý¼ì²é
__CHECKINT(dev.log_size, 1, COM_MAXLOGFILE, COM_MAXLOGFILE);
Appender *app = NULL;
switch (dev.type) {
case COM_FILEDEVICE:
_com_debug("create file appender");
app = FileAppender::getAppender(dev);
break;
case COM_NETDEVICE:
_com_debug("create net appender");
app = NetAppender::getAppender(dev);
break;
case COM_TTYDEVICE:
_com_debug("create tty appender");
app = TtyAppender::getAppender(dev);
break;
case COM_ULLOGDEVICE:
case COM_ULNETDEVICE:
_com_debug("create ul appender");
app = UlLogAppender::getAppender(dev);
break;
case COM_AFILEDEVICE:
_com_debug("create async file appender");
app = AsyncFileAppender::getAppender(dev);
break;
default:
_com_error("sorry i can't know the type[%d]", dev.type);
break;
}
if (app != NULL) {
app->setLayout(dev.layout);
_core_debug("dev =%lx appender layout=%lx", dev.layout, app->_layout);
app->_open = dev.open;
}
return app;
}