|
From: Václav Z. <vha...@gm...> - 2012-06-08 12:54:16
|
On 8 June 2012 13:52, Mika Laine <mik...@gm...> wrote:
> Hi Václav,
>
> I've been using Qt4DebugAppender and all seems to work ok. No crashes, etc.
>
> I noticed that when using qt4debugappender there comes extra carriage
> return and linefeed characters into qt creator output windows. This
> does not happen when using straight qDebug- macro. Would you have any
> idea where this comes from ?
That depends on the Layout that you are using. By default the
SimpleLayout is appending \n to the message to make one message per
line. If Qt4 does that already, you will have to use custom
PatternLayout for your appender instance without %n format specifier
at the end of the pattern layout format.
To set the layout in code do something like this:
log4cplus::tstring pattern = LOG4CPLUS_TEXT("%d{%m/%d/%y
%H:%M:%S,%Q} [%t] %-5p %c{2} %%%x%% - %m [%l]");
appender->setLayout(std::auto_ptr<Layout>(new PatternLayout(pattern)));
To do that using properties file, use something like this:
log4cplus.appender.QT=log4cplus::Qt4DebugAppender
log4cplus.appender.QT.layout=log4cplus::PatternLayout
log4cplus.appender.QT.layout.ConversionPattern=%d{%m/%d/%y %H:%M:%S}
[%t] %-5p %c - %m
The exact layout it up to you. It can be as simple as just %m
specifier to get the message.
--
VZ
|