You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-dev@logging.apache.org by Alder Netw <al...@gmail.com> on 2014/05/12 20:37:42 UTC

time stamp in log4CXXDev

  A question regarding the time-stamp control over the
log message, can the app provide its own time-stamp?
This is useful when app buffers a large amount of logs
and wish to preserve the original event generating timestamp.
  Thanks,

- Alder

Re: time stamp in log4CXXDev

Posted by Thorsten Schöning <ts...@am-soft.de>.
Guten Tag Alder Netw,
am Dienstag, 13. Mai 2014 um 02:06 schrieben Sie:

> OK, we would love to use the existing Log4cxx buffering mechanism,
> but we found the time-stamp appended by Log4Cxx is the dequeue time
> rather than the enqueue time, so the question becomes is there any
> control over using the original log generating time instead of the delivery time?

As I said before, no, not unless you re-implement the logging macros
and override the classes Logger and LoggingEvent on your own to be
able to provide a custom timestamp. What do you mean with "dequeue
time"? The timestamp used by Log4cxx is directly after constructing
the log message and therefore very close to the time when the caller
issued a log message, there's no buffering or queuing in use there.
Buffers, caches and such may only be used afterwards using appenders,
but at that moment the timestamp for the log statement issued is
already fixed.

Have a look at logger.cpp forcedLog, that's being called from the
macros.

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning       E-Mail:Thorsten.Schoening@AM-SoFT.de
AM-SoFT IT-Systeme      http://www.AM-SoFT.de/

Telefon...........05151-  9468- 55
Fax...............05151-  9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow


Re: time stamp in log4CXXDev

Posted by Alder Netw <al...@gmail.com>.
Thanks Thorsten for the prompt reply.

OK, we would love to use the existing Log4cxx buffering mechanism,
but we found the time-stamp appended by Log4Cxx is the dequeue time rather
than the enqueue time, so the question becomes is there any control over
using the original log generating time instead of the delivery time?

Thanks,


- Sherman


On Mon, May 12, 2014 at 1:47 PM, Thorsten Schöning <ts...@am-soft.de>wrote:

> Guten Tag Alder Netw,
> am Montag, 12. Mai 2014 um 20:37 schrieben Sie:
>
> >   A question regarding the time-stamp control over the
> > log message, can the app provide its own time-stamp?
>
> No, you would need to re-implement the macros LOG4CXX_* you use in
> your app, subclass Logger to override forcedLog, because that is
> called by the macros, and override LoggingEvent with an additional
> ctor which initializes timestamp different than it dies now with
> apr_time_now.
>
> > This is useful when app buffers a large amount of logs
> >  and wish to preserve the original event generating timestamp.
>
> Does this mean you create log messages on your own, buffer those and
> call log4cxx with those somewhat later? What's the benefit of doing
> this, what's your use case? Log4cxx tries to take care of such things
> using some appenders which allow buffering e.g. to save I/Os. From the
> first glance I would create a special appender implementing much of
> your use case by sticking to the default Log4cxx API.
>
> Mit freundlichen Grüßen,
>
> Thorsten Schöning
>
> --
> Thorsten Schöning       E-Mail:Thorsten.Schoening@AM-SoFT.de
> AM-SoFT IT-Systeme      http://www.AM-SoFT.de/
>
> Telefon...........05151-  9468- 55
> Fax...............05151-  9468- 88
> Mobil..............0178-8 9468- 04
>
> AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
> AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow
>
>

Re: time stamp in log4CXXDev

Posted by Thorsten Schöning <ts...@am-soft.de>.
Guten Tag Alder Netw,
am Montag, 12. Mai 2014 um 20:37 schrieben Sie:

>   A question regarding the time-stamp control over the
> log message, can the app provide its own time-stamp?

No, you would need to re-implement the macros LOG4CXX_* you use in
your app, subclass Logger to override forcedLog, because that is
called by the macros, and override LoggingEvent with an additional
ctor which initializes timestamp different than it dies now with
apr_time_now.

> This is useful when app buffers a large amount of logs
>  and wish to preserve the original event generating timestamp.

Does this mean you create log messages on your own, buffer those and
call log4cxx with those somewhat later? What's the benefit of doing
this, what's your use case? Log4cxx tries to take care of such things
using some appenders which allow buffering e.g. to save I/Os. From the
first glance I would create a special appender implementing much of
your use case by sticking to the default Log4cxx API.

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning       E-Mail:Thorsten.Schoening@AM-SoFT.de
AM-SoFT IT-Systeme      http://www.AM-SoFT.de/

Telefon...........05151-  9468- 55
Fax...............05151-  9468- 88
Mobil..............0178-8 9468- 04

AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln
AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow