log4cpp中使用PatternLayout定制输出格式

log4cpp中PatternLayout的使用

log4cpp中提供了多种layout,其中PatternLayout可以定制输出格式。看如下代码:
    PatternLayout* layout = new PatternLayout();
    layout->setConversionPattern("%d [%c] %m %n");

    Category& root = Category::getRoot();

    Appender * appender = new FileAppender("default",filename);
    appender->setLayout(layout);
    root.addAppender(appender);

你可能感兴趣的:(c,layout)