Re: [Log4cplus-devel] How do I get log4cplus to print the "header" every time?
Logging Framework for C++
Brought to you by:
wilx
From: Václav H. <wi...@us...> - 2010-02-28 09:30:18
|
Jim wrote, On 24.2.2010 23:16: > I'm obviously doing something wrong. My output looks like: > > 2010-02-24 17:08:22.138 DEBUG 3055020960 main loggerbase.cpp:3944 > Starting diagloop with 120 > -timing 118 > -timing 119 > Running procs are 0 > -Input stage activity 1 > patrol detaching > timing 0 > > but the only output I'm doing is via calls like: > Thread::sleep (50000); > outString << "timing "<<timing << endl; > LOG4CPLUS_DEBUG (root, outString.str ()); > inside of a forever loop. Obviously there are some other calls in the > loop, but this is the bit of code that generates the "timing" output. If I understand you correctly, you are asking why are you not getting "2010-02-24 17:08:22.138 DEBUG 3055020960 main loggerbase.cpp:3944" header for every line? If that is the question then the answer is because the header is only being printed for each instance of InternalLoggingEvent object that is created internally by the LOG4CPLUS_DEBUG() macro. It is not printed for each textual line of output. > > outString is > ostringstream outString; > Defined earlier in the function. > > I'm making a wild guess that the time isn't changing from call to call? > > root is defined as: > Logger root; > and assigned as > root = Logger::getInstance ("main"); > > It was preceded by: > PropertyConfigurator::doConfigure ("/etc/VA/log4cplus.properties"); > And that file looks like: > log4cplus.rootLogger=DEBUG, R > log4cplus.logger.filelogger=DEBUG, R Your filelogger is using the same appender as rootLogger. Are you not getting duplicate log entries if you log anything using the filelogger? > log4cplus.appender.R=log4cplus::RollingFileAppender > log4cplus.appender.R.File=/var/log/VA/logger.log > log4cplus.appender.R.MaxFileSize=15MB > log4cplus.appender.R.MaxBackupIndex=10 > log4cplus.appender.R.layout=log4cplus::PatternLayout > log4cplus.appender.R.layout.ConversionPattern=%D{%Y-%m-%d %H:%M:%S.%q} > %-5p %t %c %l %m%n > > Thanks for any guidance. -- VH |