You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-user@logging.apache.org by Sylvester <sy...@gmail.com> on 2008/11/22 07:49:58 UTC

Hi, unable to use Log4Cxx

Hi,
This is the first time I am using Log4Cxx. I am using MingW and eclipse 
ganymede, and for the life of me haven't figured out how to use it. I 
have added the .h files to the project they show up in the "includes". 
Then I pasted the following from here 
<http://wiki.apache.org/logging-log4cxx/FrequentlyAskedQuestions>:

#include "log4cxx/logger.h"
#include "log4cxx/helpers/pool.h"
#include "log4cxx/basicconfigurator.h"
#include "log4cxx/fileappender.h"
#include "log4cxx/simplelayout.h"



int main() {
    using namespace log4cxx;
   log4cxx::FileAppender * fileAppender = new
log4cxx::FileAppender(log4cxx::LayoutPtr(new log4cxx::SimpleLayout()),
"logfile", false);

   log4cxx::helpers::Pool p;
   fileAppender->activateOptions(p);

   
log4cxx::BasicConfigurator::configure(log4cxx::AppenderPtr(fileAppender));
   log4cxx::Logger::getRootLogger()->setLevel(log4cxx::Level::getDebug());
   log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger("logger");

   LOG4CXX_INFO(logger,"Created FileAppender appender");

   return 0;
}


Almost every line is marked red! Am I missing something? (I have made 
minor changes in the above)

Sylvester



Re: Hi, unable to use Log4Cxx

Posted by "Jacob L. Anawalt" <ja...@geckosoftware.com>.
On 2008-11-21 23:49, Sylvester wrote:
> Hi,
> This is the first time I am using Log4Cxx. I am using MingW and eclipse 
> ganymede, and for the life of me haven't figured out how to use it. I 
> have added the .h files to the project they show up in the "includes". 
> Then I pasted the following from here 
> <http://wiki.apache.org/logging-log4cxx/FrequentlyAskedQuestions>:
> 
> #include "log4cxx/logger.h"

Is this file in your source file's directory or include path? If not, are you 
using an option to specify the path to the log4cxx include folder?

Is it a compile error, or a linking error? If it is a linking error, do you have 
the log4cxx library option selected (In eclipse project properties, C/C++ Build, 
Tool Settings, C++ linker)


I'm building on a very different setup. Debian, g++ from GCC 4.1, etc. The only 
similarity is eclipse. My copy of the log4cxx headers is in my system default 
path of /usr/include/log4cxx so I include with the angle brackets, #include 
<log4cxx/logger.h> and it works without specifying an additional library 
location. I make sure I'm using -llog4cxx so the linker knows where to find the 
log4cxx objects.

I suggest trying to compile from the command line just to make sure it isn't 
some setting lost in translation to Eclipse.

-- 
Jacob Anawalt
Gecko Software, Inc.
janawalt@geckosoftware.com
435-752-8026