logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Beni Bilme <benibi...@gmail.com>
Subject Newbie Usage Question: Compile Error 'getError is not a member of log4cxx::Level'
Date Fri, 28 Mar 2008 23:32:40 GMT
I am trying to rebuild an application on Ubuntu Linux (Gutsy) which I
developed on Windows XP with VS 2003 C++ compiler some time ago. It is
Qt4 application. I am using log4cxx as well. To ease the usage, once I
posted a question to this forum and a smart fellow sent me his log.h
header file which I provided below.

I receive compile errors both at windows and at linux from the locations
that I use log_xxxx such as log_debug, log_error etc stating that
‘getError’ is not a member of ‘log4cxx::Level’. These are simple macros
as you would see below to save typing and space at the code.

I have used this code before. I have not changed anything in the code.
But I have lost the development environment in windows xp. I rebuild
libraries etc. In Ubuntu, I have just installed the distribution
libraries and tried the compile.

I do not have much knowledge about log4cxx and do not use its many
features. I just use the facilities in this header file provided below.

Note: For each class, I have a data member   'static LoggerPtr logger'
and I initialize it in the correponding cpp file as 'LoggerPtr

In the class, I use it like 'log_error("Some error message");'

Any help much appreciated.

#ifndef LOG_H
#define LOG_H

#include <log4cxx/logger.h>
using namespace log4cxx;
using namespace log4cxx::helpers;

#define _USE_LOG4CXX_ 1

#if !_USE_LOG4CXX_

#define log_fatal_enabled()  0
#define log_error_enabled()  0
#define log_warn_enabled()   0
#define log_info_enabled()   0
#define log_debug_enabled()  0
#define log_trace_enabled()  0

#define log_fatal(expr)
#define log_error(expr)
#define log_warn(expr)
#define log_info(expr)
#define log_debug(expr)
#define log_trace(expr)


#include <sstream>
#include <iosfwd>


#define log_fatal_enabled()  logger->isEnabledFor(
::log4cxx::Level::getFatal() )
#define log_error_enabled()  logger->isEnabledFor(
::log4cxx::Level::getError() )
#define log_warn_enabled()   logger->isEnabledFor(
::log4cxx::Level::getWarn()  )
#define log_info_enabled()   logger->isEnabledFor(
::log4cxx::Level::getInfo()  )
#define log_debug_enabled()  logger->isEnabledFor(
::log4cxx::Level::getDebug() )
#define log_trace_enabled()  logger->isEnabledFor(
::log4cxx::Level::getDebug() )

#define log_xxxx(level, expr) \
       do { \
       if (logger->isEnabledFor(::log4cxx::Level::level)) \
{ \
       std::ostringstream _msg_; \
       _msg_ << expr; \
       logger->log( \
       ::log4cxx::Level::level, \
       _msg_.str(), \
} \
       } while (false)

#define log_fatal(expr)  log_xxxx(getFatal(), expr)
#define log_error(expr)  log_xxxx(getError(), expr)
#define log_warn(expr)   log_xxxx(getWarn(), expr)
#define log_info(expr)   log_xxxx(getInfo(), expr)
#define log_debug(expr)  log_xxxx(getDebug(), expr)
#define log_trace(expr)  log_xxxx(getDebug(), expr)

#endif //#if !_USE_LOG4CXX

#endif // LOG_H

View raw message