文章标题 原创 翻译 转载 文章内容 log4cxx常用appender有ConsoleAppender输出到控制台,RollingFileAppender输出到文件。 在GUI程序中使用log4cxx时,要想能实时看到输出日志一般用windows函数OutputDebugString,log4cxx console appender是显示不出来的。 所以如果log4cxx的日志能向OutputDebugString一样输出就好了,没想到还真有这样一个appender,如下配置就能实现了,这样就可以用vs输出窗口或者DebugView工具实时看日志了。 log4cxx.properties ``` log4j.logger.Test=DEBUG,rfa,odsa log4j.appender.rfa=org.apache.log4j.RollingFileAppender log4j.appender.rfa.Append=true log4j.appender.rfa.File=./log/bondclient.log log4j.appender.rfa.MaxFileSize=30MB log4j.appender.rfa.MaxBackupIndex=30 log4j.appender.rfa.ImmediateFlush=true log4j.appender.rfa.layout=org.apache.log4j.PatternLayout log4j.appender.rfa.layout.ConversionPattern=[%d][%-5p][%t][%.20l] - %m%n log4j.appender.odsa=org.apache.log4j.OutputDebugStringAppender log4j.appender.odsa.layout=org.apache.log4j.PatternLayout log4j.appender.odsa.layout.ConversionPattern=[%d][%-5p][%t][%.20l] - %m%n ``` 文章类别 Python Mobile Android Java Shell Life Database Bug Windows IOS Tools Boost Node.js Mac Product Tips C/C++ Golang Javascript React Qt MQ MongoDB Design Web Linux LLM ChatGPT RAG AI 提交