I have created a sample application with log4cxx and it works great.
=====================================================
#include <log4cxx/logger.h>
#include <log4cxx/xml/domconfigurator.h>
using namespace log4cxx;
using namespace log4cxx::xml;
using namespace log4cxx::helpers;

// Define static logger variable
LoggerPtr loggerMyMain(Logger::getLogger( "main"));
LoggerPtr loggerFunctionA(Logger::getLogger( "functionA"));

void functionA()
{
    LOG4CXX_INFO(loggerFunctionA, "Executing functionA.");
}

int main()
{
    int value = 5;

    // Load XML configuration file using DOMConfigurator
    DOMConfigurator::configure("Log4cxxConfig.xml");

    LOG4CXX_TRACE(loggerMyMain, "this is a debug message for detailed code 
discovery. Value=" << value);
    LOG4CXX_DEBUG(loggerMyMain, "this is a debug message.");
    LOG4CXX_INFO (loggerMyMain, "this is a info message, ignore. Value=" << 
value);
    LOG4CXX_WARN (loggerMyMain, "this is a warn message, not too bad.");
    LOG4CXX_ERROR(loggerMyMain, "this is a error message, something serious is 
happening.");
    LOG4CXX_FATAL(loggerMyMain, "this is a fatal message!!!");

    functionA();
    return 0;
}
=============================================================================
        Requirement in our application was to create a wrapper around log4cxx 
functionality, so that in future any other logging functionality can be used 
instead of log4cxx.

        For that, we created a component, wrapping log4cxx functionality using 
software component architecture (sca) framework.

a. This wrapper component is loaded by other components or other applications
b. Component method, initialize() is called with the filename argument (xml 
properties filename )
c. Component passes the argument to DOM configurator.

Issue:
            File name passed from component to DOM configurator never gets 
passed and following is the error inside log4cxx.
"log4cxx: Could not open file [ ] "

We could observe this by setting "LogLog::setInternalDebugging( true );"
(in sample application, file name is printed instead of [] and works fine)

Which means parameter we are passing from our wrapper component to logging 
framework is failing. We have tried by passing wstring, string,  passing hard 
coded value, declaring a string variable and passing that variable....but the 
result is the same, does't work. We have even tried Configuring using other 
overloaded "configureAndWatch" functions.
a.     Void ConfigureAndWatch(filename)
                    Static Methods
b.     Void configureAnd Watch(filename, delay)
c.      Void doConfigure(filename, hierarchy)        ---------- Public method

    We were successful in logging with
 BasicConfigurator::configure() method only (but this does not accept any 
configuration filename as argument)

Any help in fixing the issue is greatly appreciated.

Reply via email to