You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-user@logging.apache.org by Barak Simon <ba...@db.com> on 2004/12/09 05:12:58 UTC

No Virtual Destructor for LoggingEvent

Hi,
I need to extend LoggingEvent to set some extra information in it,
but it seems that despite being stated in its doco:
"This class is of concern to those wishing to extend log4cxx",

the destructor is not virtual!

I know that extending it and instantiating it in a customised Logger class will break at present the SocketAppender,
but am willing to take that risk, hoping the SocketAppender future implementation will have a less strict format.

Is there any chance the next release will virtualise the LoggingEvent destructor?

Many thanks,
Barak
________________________
Barak Simon
GED IT Core Platform
Deutsche Bank
190 George St. Sydney, 2000
Phone +61 2 925 85070
Fax      +61 2 925 95050


--

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.



Re: No Virtual Destructor for LoggingEvent

Posted by Curt Arnold <ca...@houston.rr.com>.
On Dec 8, 2004, at 10:12 PM, Barak Simon wrote:

> Hi,
> I need to extend LoggingEvent to set some extra information in it,
> but it seems that despite being stated in its doco:
> "This class is of concern to those wishing to extend log4cxx",
>
> the destructor is not virtual!
>
> I know that extending it and instantiating it in a customised Logger 
> class will break at present the SocketAppender,
> but am willing to take that risk, hoping the SocketAppender future 
> implementation will have a less strict format.
>
> Is there any chance the next release will virtualise the LoggingEvent 
> destructor?
>
> Many thanks,
> Barak
> _____

I don't believe that LoggingEvent has any virtual functions (other than 
those inherited from ObjectImpl) and is not designed for extension.  
Item 15 in Effective Java is "Design and document for inheritance or 
prohibit it".  LoggingEvent is not designed or documented for 
inheritance (and intentionally so).  There isn't the C++ equivalent of 
declaring LoggingEvent as "final", but if there were I would.

You can "extend"  LoggingEvent by adding strings to the mapped 
diagnostic context, but I assume that isn't satisifactory.  If you'd 
want to discuss your use cases, maybe we could find some maintainable 
approach.