From: Václav H. <v.h...@sh...> - 2009-04-23 16:57:53
|
Semyon Kleinerman wrote, On 23.4.2009 16:10: > Hi, > I have a some difficulties in creating of custom layout. > > I have derived base log4cplus::Layout class: > > class LogLayout : public Layout > { > public: > LogLayout(void); > ~LogLayout(void); > > virtual void formatAndAppend(log4cplus::tostream& output, const > log4cplus::spi::InternalLoggingEvent& event); > }; > > The problem is that in formatAndAppend function parameters there is an > InternalLoggingEvent object only and I have no way to put *my > parameters* there. What kind of parameters do you have in mind? > > The only way I found is to format the message before I send it to logger: > > void LogLayout::formatAndAppend(log4cplus::tostream& output, > const log4cplus::spi::InternalLoggingEvent& event) > { > output << event.getMessage(); > } I think the idea is that formatting depends only on what you can get from the InternalLoggingEvent instance and the state of the layout. For that the signature of the function is adequate. > > Could you please explain me what is the right way to create a custom > layout? > Plese, don't send HTML emails. -- VH |