You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

329 lines
11 KiB

  1. Short Description
  2. =================
  3. log4cplus is a simple to use C++ logging API providing thread-safe,
  4. flexible, and arbitrarily granular control over log management and
  5. configuration. It is modeled after the Java log4j API.
  6. Latest Project Information
  7. ==========================
  8. The latest up-to-date information for this project can be found at
  9. http://log4cplus.sourceforge.net. Please submit bugs, patches,
  10. feature requests, etc. there.
  11. Tested on the following platforms
  12. =================================
  13. - Linux/AMD64 with GCC 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)
  14. - Linux/AMD64 with Sun C++ 5.12 Linux_i386 2011/11/16
  15. - Linux/AMD64 with Clang version 3.0-6ubuntu3 (tags/RELEASE_30/final)
  16. (based on LLVM 3.0)
  17. - Linux/AMD64 with Intel(R) C++ Intel(R) 64 Compiler XE for
  18. applications running on Intel(R) 64, Version 12.1 Build 20120410
  19. - FreeBSD/AMD64 with GCC 3.4.6, 4.2.1 and 4.3.3
  20. - Windows 7 with MS Visual C++ 10.0
  21. - OpenSolaris 5.11 with Sun C++ 5.10 SunOS_i386 128229-02 2009/09/21,
  22. with -library=stlport4
  23. - Solaris 5.10 with Sun C++ 5.8 2005/10/13, with -library=stlport4
  24. - NetBSD 5.0.2/AMD64 with GCC 4.1.3 20080704 prerelease (NetBSD nb2
  25. 20081120)
  26. - OpenBSD 5.0/AMD64 with GCC 4.2.1 20070719
  27. Configure script options
  28. ========================
  29. --enable-debugging
  30. ------------------
  31. This option is disabled by default. This option mainly affects GCC
  32. builds but it also has some limitted effect on non-GCC builds. It
  33. turns on debugging information generation, undefines NDEBUG symbol,
  34. adds '-fkeep-inline-functions' and '-fstack-check' (GCC).
  35. --enable-warnings
  36. -----------------
  37. This option is enabled by default. It adds platform / compiler
  38. dependent warning options to compiler command line.
  39. --enable-profiling
  40. ------------------
  41. This option is disabled by default. This option adds profiling
  42. information generation compiler option -pg to GCC and Sun CC / Solaris
  43. Studio builds.
  44. --enable-threads
  45. ----------------
  46. This option is enabled by default. It turns on detection of necessary
  47. compiler and linker flags that enable POSIX threading support.
  48. While this detection usually works well, some platforms still need
  49. help with configuration by supplying additional flags to the configure
  50. script. One of the know deficiencies is Solaris Studio on Linux. See
  51. one of the later note for details.
  52. --with-working-locale
  53. ---------------------
  54. This is one of three locale and wchar_t <-> char conversion related
  55. options. It is disabled by default.
  56. It is know to work well with GCC on Linux. Other platforms generally
  57. have lesser locale support in their implementations of the C++
  58. standard library. It is known not to work well on any *BSD.
  59. See also docs/unicode.txt.
  60. --with-working-c-locale
  61. -----------------------
  62. This is second of wchar_t <-> char conversion related options. It is
  63. disabled by default.
  64. It is known to work well on most *NIX platforms, including recent Cygwin.
  65. --with-iconv
  66. ------------
  67. This is third of wchar_t <-> char conversion related options. It is
  68. disabled by default.
  69. The conversion using iconv() function always uses "UTF-8" and
  70. "WCHAR_T" as source/target encodings. It is known to work well on
  71. platforms with GNU iconv. Different implementations of iconv() might
  72. not support "WCHAR_T" encoding selector.
  73. Either system provided iconv() or library provided libiconv() are
  74. detected and accepted. Also both SUSv3 and GNU iconv() function
  75. signatures are accepted.
  76. --with-qt
  77. ---------
  78. This option is disabled by default. It enables compilation of a
  79. separate shared library (liblog4cplusqt4debugappender) that implements
  80. Qt4DebugAppender. It requires Qt4 and pkg-config to be installed.
  81. Notes
  82. =====
  83. Cygwin/MinGW
  84. ------------
  85. Some version of GCC (3.4.x and probably some of 4.x series too) on
  86. Windows (both Mingw and Cygwin) produces lots of warnings of the form
  87. "warning: inline function 'void foo()' is declared as dllimport:
  88. attribute ignored." This can be worked around by adding
  89. -Wno-attributes option to GCC command. Unfortunatelly, not all
  90. affected version of GCC have this option.
  91. Windows and TLS
  92. ---------------
  93. log4cplus uses thread-local storage (TLS) for NDC, MDC and to optimize
  94. use of some temporary objects. On Windows there are two ways to get
  95. TLS: (1) using TlsAlloc() etc. functions, and (2) using
  96. __declspec(thread). While method (2) generates faster code, it has
  97. some limitations prior to Windows Vista. If log4cplus.dll is loaded
  98. at run time using LoadLibrary() (or as a dependency of such loaded
  99. library), then accessing __declspec(thread) variables can cause
  100. general protection fault (GPF) errors. This is because Windows prior
  101. to Windows Vista do not extend the TLS for libraries loaded at run
  102. time using LoadLibrary(). To allow using the best available method,
  103. log4cplus enables the method (2) by checking _WIN32_WINNT >= 0x0600
  104. condition, when compiling log4cplus targetted to Windows Vista or
  105. later.
  106. Threads and signals
  107. -------------------
  108. log4cplus is not safe to be used from async signals' handlers. This
  109. is a property of most threaded programmes in general. If you are
  110. going to use log4cplus in threaded application and if you want to use
  111. log4cplus from signal handlers then your only option is to block
  112. signals in all threads but one that will handle all signals. On POSIX
  113. platforms, this is possible using the sigwait() call. log4cplus
  114. enables this approach by blocking all signals in any threads created
  115. through its threads helpers.
  116. IBM's XL C/C++ compiler
  117. -----------------------
  118. IBM's XL C/C++ compiler executable has many variants ([1]). To
  119. compile log4cplus with threading support specify one of the compiler
  120. variants that support threading using the CXX variable on configure
  121. script command line. E.g.:
  122. $ ../configure --enable-threads CXX=xlC_r
  123. [1] <http://pic.dhe.ibm.com/infocenter/comphelp/v121v141/index.jsp?topic=%2Fcom.ibm.xlcpp121.aix.doc%2Fcompiler_ref%2Ftucmpinv.html>
  124. AIX reentrancy problem
  125. ----------------------
  126. There appears to be a reentracy problem with AIX 5.3 and xlC 8 which
  127. can result into a deadlock condition in some curcumstances. It is
  128. unknown whether the problem manifests with other versions of either
  129. the OS or the compiler, too. The problem was initially reported in a
  130. bug report #3056687 ([1]).
  131. The core of the problem is that IBM's/xlC's standard C++ IOStreams
  132. implementation uses global non recursive lock to protect some of its
  133. state. The application in the bug report was trying to do logging
  134. using log4cplus from inside overflow() member function of a class
  135. derived from std::streambuf class. log4cplus itself uses
  136. std::ostringstream. This resulted into an attempt to recursivly lock
  137. the global non recursive lock and a deadlock.
  138. [1] <https://sourceforge.net/tracker/?func=detail&aid=3056687&group_id=40830&atid=429073>
  139. Solaris / SunOS
  140. ---------------
  141. Some older version of this operating system might have problems
  142. linking log4cplus due to missing __tls_get_addr ([1]) in their
  143. unpatched state.
  144. [1] <https://groups.google.com/d/msg/comp.unix.solaris/AAMqkK0QZ6U/zlkVKA1L_QcJ>
  145. Solaris Studio
  146. --------------
  147. Solaris Studio compilers' default standard C++ library is very
  148. non-standard. It seems that it is not conforming enough in, e.g., Sun
  149. C++ 5.12 Linux_i386 2011/11/16 (missing std::time_t, etc.), but it
  150. works well enough on Solaris with Sun C++ 5.8 2005/10/13. Thus
  151. log4cplus adds -library=stlport4 to the CXXFLAGS environment variable,
  152. unless a switch matching -library=(stlport4|stdcxx4|Cstd) is already
  153. present there. If you want to override the default supplied by
  154. log4cplus, just set it into CXXFLAGS on configure script command line.
  155. Solaris Studio supports the __func__ symbol which can be used by
  156. log4cplus to record function name in logged events. To enable this
  157. feature, add '-features=extensions' switch to CXXFLAGS for configure
  158. script. Subsequently, you will have to add this switch to your
  159. application's build flags as well.
  160. Solaris Studio on GNU/Linux
  161. ---------------------------
  162. The autotools and our configure.in combo does not handle Solaris
  163. Studio compiler on Linux well enough and needs a little help with
  164. configuration of POSIX threads:
  165. $ COMMON_FLAGS="-L/lib/x86_64-linux-gnu/ -L/usr/lib/x86_64-linux-gnu/ \
  166. -mt=yes -O"
  167. $ ../configure --enable-threads=yes CC=/opt/solarisstudio12.3/bin/cc \
  168. CXX=/opt/solarisstudio12.3/bin/CC CFLAGS="$COMMON_FLAGS" \
  169. CXXFLAGS="$COMMON_FLAGS" LDFLAGS="-lpthread"
  170. Qt / Win32 / MSVC
  171. -----------------
  172. In order to use log4cplus in Qt programs it is necessary to set
  173. following option:
  174. Treat WChar_t As Built in Type: No (/Zc:wchar_t-)
  175. Set this option for log4cplus project and Qt4DebugAppender project in
  176. MS Visual Studio. Remember to use Unicode versions of log4cplus
  177. libraries with Qt. It is also necessary to make clear distinction
  178. between debug and release builds of Qt project and log4cplus. Do not
  179. use log4cplus release library with debug version of Qt program or vice
  180. versa.
  181. For registering Qt4DebugAppender library at run-time call this method:
  182. log4cplus::Qt4DebugAppender::registerAppender() ;
  183. Add these lines to qmake project file for using log4cplus and
  184. Qt4DebugAppender:
  185. INCLUDEPATH += C:\log4cplus\include
  186. win32 {
  187. CONFIG(debug, debug|release) {
  188. LIBS += -LC:\log4cplus\msvc10\Win32\bin.Debug_Unicode -llog4cplusUD
  189. LIBS += -LC:\log4cplus\msvc10\Win32\bin.Debug_Unicode -llog4cplus-Qt4DebugAppender
  190. } else {
  191. LIBS += -LC:\log4cplus\msvc10\Win32\bin.Release_Unicode -llog4cplusU
  192. LIBS += -LC:\log4cplus\msvc10\Win32\bin.Release_Unicode -llog4cplus-Qt4DebugAppender
  193. }
  194. }
  195. LOG4CPLUS_*_FMT() and UNICODE
  196. -----------------------------
  197. Beware, the %s specifier does not work the same way on *NIX as it does
  198. on Windows with Visual Studio. With Visual Studio the %s specifier
  199. changes its meaning conveniently by printing wchar_t string when used
  200. with wprintf() and char strings when used with wprintf(). On the
  201. other hand, *NIX keeps the meaning of printing char strings when used
  202. with both wprintf() and printf(). It is necessary to use %ls (C99)
  203. specifier or %S (SUSv2) specifier to print wchar_t strings on *NIX.
  204. The common ground for both platforms appears to be use of %ls and
  205. wchar_t string to print strings with unmodified formatting string
  206. argument on both *NIX and Windows. The conversion of wchar_t back to
  207. char then depends on C locale.
  208. C++11 support
  209. -------------
  210. log4cplus contains small amount of code that uses C++11 (ISO/IEC
  211. 14882:2011 standard) language features. C++11 features are used only
  212. if C++11 support is detected during compile time. Compiling log4cplus
  213. with C++11 compiler and standard library and using it with C++03
  214. (ISO/IEC 14882:2003 standard) application is not supported.
  215. Unsupported compilers
  216. ---------------------
  217. log4cplus does not support too old or broken C++ compilers:
  218. - Visual C++ prior to 7.1
  219. - GCC prior to 3.2
  220. - All Borland/CodeGear/Embarcadero C++ compilers
  221. Unsupported platforms
  222. ---------------------
  223. log4cplus requires some minimal set of C and/or C++ library
  224. functions. Some systems/platforms fail to provide these functions and
  225. thus log4cplus cannot be supported there:
  226. - Windows CE - missing implementations of <time.h> functions
  227. License
  228. =======
  229. This library is licensed under the Apache Public License 2.0 and two
  230. clause BSD license. Please read the included LICENSE file for
  231. details.