Re: [Log4cplus-devel] Header line for file appenders
Logging Framework for C++
Brought to you by:
wilx
From: Václav Z. <vha...@gm...> - 2014-01-29 22:36:07
|
On 01/29/2014 07:20 PM, Steve Hartmann wrote: > > > On 1/29/14 3:38 AM, "Václav Zeman" <vha...@gm...> wrote: > >> It seems to me that layout would be a better place for this. >> >> Is there a prior art for this feature in log4j (or any other Java >> logging library) or log4net, etc.? We could copy their design >> decisions / interfaces. >> > > With log4j, you have to extend the layout. Here is a link to an article > on how to use it: > http://www.coderanch.com/t/535099/oa/Inserting-Header-Text-Log-file > > Personally, I would like to just have it built in as a property - what do > you think? > Yeah, I do not think that having to derive own layout is the way to go. It should be built-in. I am not sure if it should be in PatternLayout (and TTCCLayout) only or if it should be part of the base Layout class; Adding the header information to a new base class, that would be between Layout and PatternLayout does not sound wrong to me. I can imagine a layout without a need for a header (e.g., XMLLayout). But adding it to the base class would be a lot less intrusive. (...) OK, my suggestion is to keep Layout, SimpleLayout and TTCCLayout as they are, no header. Add a new base class, say, LayoutHeader with virtual tstring getHeader() const = 0 member function and inherit from this new base class and implement the pure virtual member function in PatternLayout. Use dynamic_cast<LayoutHeader *> to test for header availability in appenders where it makes any sense. -- VZ |