1

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 ?

4

2 回答 2

1

尝试"myLogFile.log"像这样包装:LOG4CPLUS_TEXT("myLogFile.log"). 您也可以使用_T()宏,因为您在 Windows 上使用 Visual Studio。

于 2012-11-15T06:36:14.810 回答
0

我不知道什么是类型log4cplus::tstring,但假设它是一种typedef类似于std::basic_string<cT>(甚至可能是除 之外std::basic_string<cT>的类型)的类型,您可以尝试以下其中一种:cTchar

SharedAppenderPtr app1(new FileAppender(L"myLogFile.log"));
std::string name("myLogFile.log");
SharedApppenderPtr app2(new FileAppender(log4cplus::tstring(name.begin(), name.end())));
于 2012-11-14T22:47:48.243 回答