I have a properties-based log4cxx called Log4cxxConfig.cfg. In it I added a named logger called log4j.daemon. I also created an appender called QTermDaemonAppender. Here is a portion of the cfg file:
log4j.rootLogger=info, rootFileAppender
log4j.StationControllertest=trace, rootConsoleAppender, rootFileAppender
log4j.log4test=trace, rootConsoleAppender
log4j.daemon=trace, QTermDaemonAppender
# QTermDaemonAppender
log4j.appender.QTermDaemonAppender.File=qterm_daemon.log
log4j.appender.QTermDaemonAppender.Append=true # set whether to overwrite or append to the file
log4j.appender.QTermDaemonAppender.MaxFileSize=10000KB
log4j.appender.QTermDaemonAppender.MaxBackupIndex=10
log4j.appender.QTermDaemonAppender=org.apache.log4j.RollingFileAppender
log4j.appender.QTermDaemonAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.QTermDaemonAppender.layout.ConversionPattern=%5p %d [%t] (%F:%L) - %m%n
In my C++ code I have tried everything I can think of to get my output to write to qterm_daemon.log. The file is not created in addition to having nothing written to it.
LoggerPtr logger(Logger::getLogger("daemon"));
int main(int argc, char* argv[])
{
// Initialise logger. Use the configuration file named 'log4cxx.properties'.
PropertyConfigurator::configureAndWatch("Log4cxxConfig.cfg");
I've tried the above. I've tried qualifying the name of the cfg file like "./Log4cxxConfig.cfg". I've searched my path for duplicates of this file. I've tried using the logger name "log4j.daemon" instead of "daemon".
I've tried the following:
int main(int argc, char* argv[])
{
// Initialise logger. Use the configuration file named 'log4cxx.properties'.
PropertyConfigurator::configureAndWatch("Log4cxxConfig.cfg");
LoggerPtr logger(Logger::getLogger("log4j.daemon"));
Again, with various combinations of qualifying the path and changing the name of the logger name. No joy! What in the heck am I doing wrong? I can get this to work like a champ with Java and log4j1.4 on an AS400. BTW, this is with Raspbian and the new Pi 2.