logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lev Lvovsky <lis...@sonous.com>
Subject unused precompiler directive for syslog functionality
Date Wed, 09 Nov 2005 22:03:47 GMT
Hello,

In RE to my email yesterday about the syslog functionality of log4cxx  
not working on Mac OS X (10.4.3):

My system has the "syslog.h" header for syslogd logging  
functionality, and subsequently upon looking for the code, there're  
some tests for this file:

Using the latest 0.9.8 source the precompiler directive  
"LOG4CXX_HAVE_SYSLOG" is initially defined in the "include/log4cxx/ 
private/log4cxx_private.h" header file, however the header file  
cannot be included in other source without "-DLOG4CXX_TEST" or "- 
DLOG4CXX" being added to the compiler options, else the following  
message shows up:

---
#error "log4cxx/private/log4cxx_private.h should only be used within  
log4cxx implementation or tests"
---

By implementation, does that mean 'whenever I'd like to use  
log4cxx'?  Otherwise, the following block in syslogappender.cpp,  
which actually invokes the syslog() function doesn't get entered...

---
<syslogappender.cpp>
     261 #ifdef LOG4CXX_HAVE_SYSLOG
     262         if (sw == 0)
     263         {
     264                 std::string sbuf;
     265                 Transcoder::encode(msg, sbuf);
     266
     267                 // use of "%s" to avoid a security hole
     268                  ::syslog(syslogFacility | event->getLevel()- 
 >getSyslogEquivalent(),
     269                         "%s", sbuf.c_str());
     270
     271                 return;
     272         }
     273 #endif
---

As a stopgap, I "#define LOG4CXX 1", and "#include <log4cxx/private/ 
log4cxx_private.h>" in the "syslogappender.h" header file before the  
"LOG4CXX_HAVE_SYSLOG" precompiler variable gets checked.  I'm  
assuming there's either something wrong in the way I'm doing things,  
or there's something wrong in the header files.

Thanks!
-lev

Mime
View raw message