tags:

views:

25

answers:

0

Greetings,

I'm having trouble finding a good solution for initializing LoggingEvent.timeStamp to a custom value. In short, in our system machine time is meaningless and we want all our logs etc to use a "simutime" ie simulation time.

What would be ideal is if we could somehow instruct log4cxx to everywhere instantiate say MyLoggingEvent instead of the provided LoggingEvent. The constructor of this custom event would reset timeStamp to the simutime for example (ignoring for now the fact that LoggingEvent.timeStamp is private):

class MyLoggingEvent : public LoggingEvent { public : MyLoggingEvent ( ... ) : LoggingEvent(...) { timeStamp = simuTime() ; } ... } ;

Can someone please advise on the proper approach for this customization? Ie is there an canonical way of injecting custom LoggingEvent classes?

I thought about custom LoggingEvent + Logger + LoggerFactory; but, that does not seem like it will work well and the docs suggest that custom factories are discouraged. On the other hand, if I write a custom Appender then I would need to code one for every one of appenders that we use. So I'm lost ... Short of modifying the core log4cxx code, which we are trying to avoid, I don't know what to do.

Thanks!

KHD