KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I've been struggling with boost log for a while now - I got their simple example writing to a log file ( http://boost-log.sourceforge.net/libs/log/example/doc/tutorial_file.cpp ). However, when I try to copy that code into a 'Logger' class, I can't get it to write to the log file. I can see the file default.log get created, but there is nothing in it. I'm on debian 7 64bit. Everything compiles fine - compile line is: g++ -o build/Logger.o -c -std=c++11 -Wall -g -O0 -DBOOST_LOG_DYN_LINK -DDEBUG src/Logger.cpp g++ -o build/logtest build/Logger.o -lboost_log -lboost_log_setup -lboost_date_time -lboost_thread -lboost_wave -lboost_regex -lboost_program_options Here's my code: Logger.cpp /* * Logger.cpp * * Created on: 2011-01-17 * Author: jarrett */ #include "Logger.h" namespace logging = boost::log; namespace sinks = boost::log::sinks; namespace src = boost::log::sources; namespace expr = boost::log::expressions; namespace attrs = boost::log::attributes; namespace keywords = boost::log::keywords; namespace dhlogging { Logger::Logger(std::string fileName) { initialize(fileName); } Logger::Logger(Logger const&) { } Logger::~Logger() { } Logger* Logger::logger_ = nullptr; Logger* Logger::getInstance(std::string logFile) { if ( Logger::logger_ == nullptr ) { logging::add_file_log( logFile ); logging::core::get()->set_filter ( logging::trivial::severity >= logging::trivial::info ); logging::add_common_attributes(); Logger::logger_ = new Logger(logFile); } return Logger::logger_; } void Logger::initialize(std::string fileName) { BOOST_LOG(log_) << "Hello, World!"; BOOST_LOG_SEV(log_, info) << "Hello, World2!"; } void Logger::logInfo(std::string messa
Tags (comma-separated)
Save Edits
Cancel