logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From david.we...@l-3com.com
Subject Modifying logFilePath for FileAppender using a PropertyConfigurator
Date Mon, 08 Dec 2008 18:29:48 GMT
I am trying to configure log4cxx to write its logging messages to a log
file. The path to the log file is not known until run-time. The way that
I was going to go about doing this is by creating a
log4cxx::helpers::Properties object, setting the property and then
passing the Properties object to the PropertyConfigurator.
Here is the sample code I was using:
**** Start Sample Code ****
log4cxx::helpers::Properties loggerProperties;
const LogString key = "log4j.appender.file.File"; // Line 55
const LogString value = logFilePath.string(); // Line 56 logFilePath is
a boost::filesystem::path object
loggerProperties.setProperty(key, value);
**** End Sample Code ****
The problem is that the log4cxx software is built to support UNICODE so
the initialization of the key and value variables does not compile. Here
are the error messages:
Controller.cpp(55) : error C2440: 'initializing' : cannot convert from
'const char [25]' to 'std::basic_string<_Elem,_Traits,_Ax> with
r_t>]'; No constructor could take the source type, or constructor over
load resolution was ambiguous
Controller.cpp(56) : error C2440: 'initializing' : cannot convert from
'const boost::filesystem::basic_path<String,Traits>::string_type with
[String=std::string,Traits=boost::filesystem::path_traits]' to
'std::basic_string<_Elem,_Traits,_Ax> with
r_t>]'; No constructor could take the source type, or constructor
overload resolution was ambiguous
Looking within the logstring.h file I found the LOG4CXX_STR macro which
can be added to line 55 to make the first error message go away (I think
because the macro converts my literal string to a UNICODE literal
string). How can I achieve the same effect for the data within the
logFilePath variable (whose value is only known at run-time)?

View raw message