Skip to content

Instantly share code, notes, and snippets.

@zerohours
Created February 21, 2013 03:19
Show Gist options
  • Save zerohours/5001768 to your computer and use it in GitHub Desktop.
Save zerohours/5001768 to your computer and use it in GitHub Desktop.
/*
* log.cpp
*
* Copyright 2013 Julio Cesar Brizuela @zerohours
*
*/
#include <iostream>
#include <log4cpp/Category.hh>
#include <log4cpp/FileAppender.hh>
#include <log4cpp/SimpleLayout.hh>
#define LOGFILE "/home/usuario/test.log"
int main()
{
/*Setting up Appender, layout and Category*/
log4cpp::Appender *appender = new log4cpp::FileAppender("FileAppender",LOGFILE);
log4cpp::Layout *layout = new log4cpp::SimpleLayout();
log4cpp::Category& category = log4cpp::Category::getInstance("Category");
appender->setLayout(layout);
category.setAppender(appender);
category.setPriority(log4cpp::Priority::INFO);
/*The actual logging*/
category.info("Esto es para trazar el flujo de sistema");
category.notice("Esto es para notificar determinados eventos");
category.warn("Esto es para generar ciertas advertencias");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment