Reputation: 181
I want to implement AsyncAppender
in log4cplus to write the event asynchronously into the file. Please guide me with any sample code.
Upvotes: 2
Views: 1453
Reputation: 18248
If you are not using log4cplus master branch but one of the released versions then you should be able to use this configuration to wrap, e.g., FileAppender
with AsyncAppender
:
log4cplus.appender.TEST=log4cplus::AsyncAppender
log4cplus.appender.TEST.Appender=log4cplus::FileAppender
log4cplus.appender.TEST.Appender.File=test_output.log
log4cplus.appender.TEST.Appender.layout=log4cplus::PatternLayout
log4cplus.appender.TEST.Appender.layout.ConversionPattern=%d{%y-%m-%d %H:%M:%S,%q} [%t] %-5p %c <%x> - %m%n
If you are using master branch of log4cplus Git repository then all you need to do is to set AsyncAppend
property of your appender to true
and the magic will happen.
Upvotes: 3