Search code examples
c++log4cplus

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 ?


Solution

  • 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.