Try wrapping the "myLogFile.log"
like this: LOG4CPLUS_TEXT("myLogFile.log")
. You could also use the _T()
macro, since you are on Windows with Visual Studio.
Log4cplus char* and tstring issue with FileAppender
سؤال
I have two projects with almost the same configuration in visual studio 2010 One with the console works and gives no trouble with the statement
SharedAppenderPtr myAppender(new FileAppender("myLogFile.log"));
While the other project a dll project gives trouble with the same statement
SharedAppenderPtr myAppender(new FileAppender("myLogFile.log"));
The error message is:
Error 3 error C2664: 'log4cplus::FileAppender::FileAppender(const log4cplus::tstring &,std::ios_base::openmode,bool)' : cannot convert parameter 1 from 'const char [10]' to 'const log4cplus::tstring &'
Any suggestions on how I could resolve this issue ?
المحلول
نصائح أخرى
I don't know what type log4cplus::tstring
is but assuming it is a typedef
for a type similar to std::basic_string<cT>
(possibly even std::basic_string<cT>
with a type cT
other than char
) you might try one of these:
SharedAppenderPtr app1(new FileAppender(L"myLogFile.log"));
std::string name("myLogFile.log");
SharedApppenderPtr app2(new FileAppender(log4cplus::tstring(name.begin(), name.end())));