The purpose of this project is to port the excellent Log for Java (log4j) logging library to C++.
See all
Members (150)
log4cplus's profile photo
Yin laiyier's profile photo
Yelli Cazalon's profile photo
Martin Runge's profile photo
Linus Lirpa (Tobias W.)'s profile photo
Musten Jiruwala's profile photo
Václav Haisman's profile photo
Manikandan Thirugnanam's profile photo
Andreas Roth's profile photo
christopher dawes's profile photo
Maria Vineeta's profile photo
Rochmat Mustopa's profile photo
Hoeshin Jeong's profile photo
Géry Vessère's profile photo
Kwang Joon Park's profile photo
Myeongho AN's profile photo
Subhamoy Sengupta's profile photo
Jim Hague's profile photo
Cen Rao's profile photo
BHASKARADS's profile photo
Sarvagya Pant's profile photo
DrDoom77's profile photo
Kyle Leber's profile photo
Ryan Thompson's profile photo

Stream

Join this community to post or comment
 
I've been using log4cplus-1.2.0-rc3 in my application for some time; it works great linked dynamically. But, for portability reasons, I find that I must switch all libraries to being statically linked. I have done this easily by using BUILD_SHARED_LIBS=false, linking against log4cplusS, and adding '# define LOG4CPLUS_STATIC' to the appropriate header. However, I now find that linking fails specifically on log4cplus: 'undefined reference to log4cplus::BasicConfigurator'...etc. Any idea why?
1
Stuart Bowman's profile photo
 
Never mind. I appear to have solved it. A lower-level library was also linking against log4cplus, but still doing it dynamically. Once I fixed that, everything built again and my test pass. Thanks!
Add a comment...

log4cplus
owner

Diskuse  - 
 
 
I have released log4cplus 1.2.0. The changes from the last release candidate are minimal:

- Fixed SourceForge bug #324, MinGW compilation issue. Use InterlockedExchangeAdd instead of InterlockedAdd. The former is supported by older MinGW.

- Fixed GitHub bug #137. Fix missing thread's alternative name.
1
Add a comment...
 
Hi,

do log4cplus::PatternLayout has some way to output date-time in ISO 8601 full format, in UTC time + TZD (Time Zone Designator)?
I.e. 1994-11-05T08:15:30+01:00

As an alternative, does PatternLayout support the %z (lowercase), supported by strftime since C99?
1
Václav Haisman's profile photoRoal Zanazzi's profile photo
2 comments
 
Ok, I found the problem.
I was using the log4cplus (oldish 1.1.2-rc2) compiled by a co-worker with Microsoft Visual Studio 2013 that seems to not correctly support strftime the %z formatter option (outputs the TZ name instead of TZD).

I rebuilt the library with Visual Studio 2015 and now %z correctly outputs "+100" in my case.

Thanks for your time.
Add a comment...
 
Hello there,

 I've an issue with an  application using log4cplus that, sincerely, gets me puzzled. The application is multithread, having 2 threads for two log4cplus appenders: A time & size rolling appender used for the main log, and a custom appender for access log (this is a HTTP based server).

 This application runs in many different customers and testing servers, from bare metal servers to VMs, and now even container'd docker environment. No problem at all, but in one customer; in this one, the logging gets blocked, and nothing else is written until the application is restarted.

 No specific behavior, no rules and no pattern: it just happens, sometimes more in one of the nodes, sometimes does not happen for weeks, and then happens in several nodes the same time.

 This customer is running the app in many VMs under ESXi with the VM images stored (and reading / writing) in a HP SAN. The only thing writing to disk is the log itself, no other application is running, and the kernel and system logs does not show this problem. There are two datacenters, with two similar SANs and two ESX clusters, and this is happening on both DCs.

 Debugging on this machine is difficult,  I'm setting up the environment with the customer, but preliminary tests have shown that the logging threads are blocked in a waitpid() call.

As said, this is running in dozens of other customers, with similar environments (but the SAN) and it's running just fine, no problems. Logs from ESXi / VCenter and the SAN monitoring do not show anything clear, there are no errors or nothing suspicious there.

 Any suggestion here would be really welcome, this has been happening for a while and nothing of the different things I've been testing seem to bring more information or anything clear about the issue?

 Thanks!
1
Alberto Curro's profile photoVáclav Haisman's profile photo
6 comments
 
+Alberto Curro Please do keep me posted. Is this happening during some special time like startup or shutdown? If you have some call stacks, you can send them to my email vhaisman@gmail.com, to keep them private. 
Add a comment...
 
Documentation of log4cplus is very weak. However there some examples in order to shallowly use it but I couldn't find any deep information about the library. For instance, "spi" namespace and classes in this namespace are very blurry. One can understand it by investigating the code but it takes more time. Do you know any detailed tutorial or document for log4cplus ?
2
1
Václav Haisman's profile photo
Add a comment...

Ashwin D

Diskuse  - 
 
Is it possible to create Log4cplus as s static library... While configuring, i mentioned --enable-static.. But its not creating .a file, rather again creating so files. Is any other way to create as a static library. 
1
Ashwin D's profile photoVáclav Haisman's profile photo
3 comments
 
+Ashwin D That might be the problem. Can you post config.log for somewhere for inspection or send it to my email vhaisman@gmail.com, if you want to keep it private.
Add a comment...
 
Hi,

why do i need the log4cplus.dll in my folders?
Can i compile the Sourcecode that i doesn't need the dll?
1
Tobias Dornheim's profile photoVáclav Haisman's profile photo
3 comments
 
Your code needs to define LOG4CPLUS_STATIC preprocessor symbol. Do not forget to set up includes and libraries paths and/or add log4cplusS to your projects References.
Add a comment...

log4cplus
owner

Diskuse  - 
 
 
log4cplus 1.1.3-RC4 released

- Allow negative maximal length in pattern specifier to make trimming of end instead of beginning possible. E.g., allow %.-1p to get initial letters of log level.

- Visual Studio DLL builds now have a resource with basic information about the library. (Oskari Timperi)

- LOG4CPLUS_*_FMT() macros can now be invoked with just formatting string, without additional arguments. (Zhang Shengfa)

- Added setCurrentThreadName() and setCurrentThreadName2() to allow setting current thread name to custom string instead of the default stringified thread ID. (Zhang Shengfa)
1
Add a comment...
 
We have integrated this simple to use log4cplus in Adone InDesign CC (an application) using PlugIns on Mac as well as Windows. However, InDesign needs to be started in Admin mode for RollingFileAppender to be able to create the log file. I would like this to be created without having to start the application in Admin mode. How do I achieve this? Thank you for your help in advance.
1
Václav Haisman's profile photoMusten Jiruwala's profile photo
4 comments
 
Cool. Thank you very much for information.
Add a comment...
 
I am trying to compile some of my old software, where I had used Log4CPlus. I found it like this in CMake:

find_path(LOG4CPLUS_INCLUDE_DIRS log4cplus/logger.h
          HINTS "/usr/include/" "/usr/local/include/"
          PATH_SUFFIXES log4cplus )

find_library(LOG4CPLUS_LIBS NAMES liblog4cplus.a liblog4cplus.la liblog4cplus.so
             HINTS "/usr/lib/" "/usr/local/lib"
             PATH_SUFFIXES x86_64-linux-gnu )

I am trying to compile the code again, and I just installed the 1.0.4 version from the repos. CMake does not complain, but Make fails afterwards with this error:

/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../lib/liblog4cplus.a(logger.o): relocation R_X86_64_32S against `_ZTVN9log4cplus6LoggerE' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../lib/liblog4cplus.a: error adding symbols: Bad value

I am suing Ubuntu Trusty, GCC 4.9.1. Am I doing something wrong? How do I do it right?
1
Václav Haisman's profile photoSubhamoy Sengupta's profile photo
2 comments
 
I have removed all static archives. My idea was to give someone the binary, who would not take the trouble of finding and installing the right versions of everything. But I will find another way :) Thank you! I still make silly mistakes with CMake sometimes.
Add a comment...

Created by

About this community

log4cplus is a simple to use C++ logging API providing thread-safe, flexible, and arbitrarily granular control over log management and configuration. It is modelled after the Java log4j API.

Io Carmine

Diskuse  - 
 
Hi, is there a way to have the PID as part of the filename in the configration of a FileAppender. I have more processes and I would like them to share the same config file but to have each of them writing in its own log file. Is this possible to achieve with log4cplus?

something like: 

log4cplus.appender.LOG=log4cplus::FileAppender
log4cplus.appender.LOG.File=c:\temp\trace_p-%-5.5p.log
1
Václav Haisman's profile photo
 
No, there is no way to do that directly. You could get a similar effect by defining some environment variable and using it in the file name like ${FOO}.
Add a comment...

log4cplus
owner

Diskuse  - 
 
I have released log4cplus 1.2.0-RC6:

- Fixed Visual Studio build issue #322 related to WinSock functions being used and second about C++11 syntax. This forces minimum version of Windows supported by this release to Windows XP SP2.

- Added DatePattern property to DailyRollingFileAppender configuration -- This property specifies filename suffix pattern to use for periodical backups of the logfile. (Alexey Morozov)

- Added RollOnClose property to DailyRollingFileAppender and TimeBasedRollingFileAppender configuration -- This property specifies whether to rollover log files upon shutdown. By default it's set to true to retain compatibility with legacy code. (Alexey Morozov)

- Normalized line endings, used .gitattributes to enforce it.

https://sourceforge.net/p/log4cplus/news/2016/01/log4cplus-120-rc6-released/
1
2
Václav Haisman's profile photoLinus Lirpa (Tobias W.)'s profile photo
Add a comment...
 
i have this below configuration, but when file created. that file was empty. can any body help me?

log4cplus.rootLogger=DEBUG, STDOUT
log4cplus.logger.testlogger=TRACE, TEST
log4cplus.additivity.testlogger=FALSE

log4cplus.appender.STDOUT=log4cplus::ConsoleAppender
log4cplus.appender.STDOUT.layout=log4cplus::PatternLayout
log4cplus.appender.STDOUT.layout.ConversionPattern=%D{%m/%d/%y %H:%M:%S }  %n
log4cplus.appender.TEST=log4cplus::TimeBasedRollingFileAppender
log4cplus.appender.TEST.Schedule = DAILY
log4cplus.appender.TEST.FilenamePattern=%d_biller.log
log4cplus.appender.TEST.layout=log4cplus::PatternLayout
log4cplus.appender.TEST.layout.ConversionPattern=%D{%Y-%m-%d %H:%M:%S} %-5p %c <%x> - %m%n
1
Václav Haisman's profile photo
 
Try to run your test with environment variable `LOG4CPLUS_LOGLOG_DEBUGENABLED` set to 1. It will print out some information about file rollovers during run time.
Add a comment...
 
Hi!

I'm trying to compile the downloaded source (master) on my debian (jessie, 64bit) system and I always got the following error when I make it:

src/global-init.cxx:35:24: fatal error: ThreadPool.h: No such file or directory
  #include "ThreadPool.h"
                        ^
compilation terminated.
Makefile:2113: recipe for target 'src/liblog4cplus_la-global-init.lo' failed
make[2]: * [src/liblog4cplus_la-global-init.lo] Error 1
make[2]: Leaving directory '/root/log4cplus-master'
Makefile:2617: recipe for target 'all-recursive' failed
make[1]: * [all-recursive] Error 1
make[1]: Leaving directory '/root/log4cplus-master'
Makefile:1450: recipe for target 'all' failed
make: * [all] Error 2

Some lib is missing from my system?
What should I do ?

Thanks!
1
Václav Haisman's profile photoCsaba Bordás's profile photo
2 comments
 
Thanks for your answer!
Helped a lot!
I figured it out! Now it works fine!
Add a comment...

Ashwin D

Diskuse  - 
 
i had generated liblog4cplus.a static library, i tried using the same with necessary libs in my project. It throws log4cplusinitialize referenced symbol not found... And while creating a my .so along with static log4cplus.a lib, i got a ld:warning like " loblog4cplus.configurator" wrong ELFCLASS 32..Do i need to create 64 bit lib, if any suggestions how to do it.... if not what mite be the above error(referenced symbol not found) due to?  any idea.. 
1
Václav Haisman's profile photoAshwin D's profile photo
2 comments
 
Nothing!!. Actuallt i had configured the download wirh the following: " Configure --enable-static. And i done "make" and  i got the liblog4cplus.a file, which i want to use in my project as a static link library. While doing that i got ELFCLASS32 warning, so i wanted to make the library as compatible for 64 bit.. i am sorry if i confused you. Any idea on that..Or do u require myy config files....
Add a comment...

Ashwin D

Diskuse  - 
 
Hi , I want to use log4cplus for a c++ project in solaris. What do i need to do first? 
1
Václav Haisman's profile photoAshwin D's profile photo
7 comments
 
+Václav Haisman sure...
Add a comment...
 
Is there an Ubuntu repository, from where I can get the latest and greatest of this? The version in the Trusty Canonical repos is too old.
1
Václav Haisman's profile photo
 
As far as I know, there is not any. 
Add a comment...

log4cplus
owner

Diskuse  - 
 
 
*log4cplus 1.2.0-RC3 released*

- Fixed various issues related to unspecified behaviors which manifested when log4cplus was compiled using Clang.
SysLogAppender now recognize SyslogHost property as synonym for host property.

- Improved compatibility of TTCCLayout with log4j's. Added ThreadPrinting, CategoryPrefixing and ContextPrinting configuration properties.

- Allow negative maximal length in pattern specifier to make trimming of end instead of beginning possible. E.g., allow %.-1p to get initial letters of log level.

- New appender TimeBasedRollingFileAppender. (Alexander Malinin)
LOG4CPLUS_*_FMT() macros can now be invoked with just formatting string, without additional arguments. (Zhang Shengfa)

- Insert to/from string/log level conversion functions to the beginning of vector to favour user defined log levels and conversion functions.
1
Add a comment...

Kyle Leber

Diskuse  - 
 
Does the log4cplus pattern layout support the use of a log level initial instead of the full word?  Basically I'm looking to output E, W, I, D, or T for Error, Warn, Info, Debug, or Trace.
1
Václav Haisman's profile photoKyle Leber's profile photo
4 comments
 
Great thanks!
Add a comment...