Hi All ,
Currently is there any way to print the timestamps/dates in log4cpp
converted to GMT/UTC timezone. I read somewhere that using "%d" prints
the date in UTC but we are still getting our local system (US) time.
Any help regarding this will be deeply appreciated.
No, there is no way to print UTC time using PatternLayout. But you can write your own appender that will print UTC timestamps/date.
That is at odds with documentation claiming that %d prints UTC, and %D local time.
So I checked the code in log4cpp-1.1.3.tar.gz for the facts. It looks like it's always localtime:
std::time_t t = event.timeStamp.getSeconds();
localtime(&t, ¤tTime);
Perhaps you could simply patch that line to use gmtime instead.
According to this old thread, there is no support:
That is at odds with documentation claiming that %d prints UTC, and %D local time.
So I checked the code in log4cpp-1.1.3.tar.gz for the facts. It looks like it's always
localtime
:Perhaps you could simply patch that line to use
gmtime
instead.