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.

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