Guten Tag Nandan S, am Samstag, 8. Februar 2014 um 11:16 schrieben Sie: > I am still thinking of this and not sure, how can i achieve filename and > line number to be printed correctly.
You need to make your wrapper capable of providing this information to LOG4CXX core. I created a simple wrapper for some legacy code which is implemented as a class with a ctor getting file and function information, saving that in the instance and methods like trace, debug etc. providing the line information. Afterwards you can redefine the macro which Log4cxx uses to use the information of this wrapper. But I only use this wrapper for very few log statements and don't think that your approach with wrapping Log4cxx is worth your efforts. Log4cxxNonCppWrapper( std::wstring configFilePath, std::wstring logger, std::string file, std::string function); void trace( std::wstring message, int line, std::string function = ""); #pragma warn -8017 #define LOG4CXX_LOCATION ::log4cxx::spi::LocationInfo( \ this->file.c_str(), \ function.empty() ? this->function.c_str() : function.c_str(), \ line) #pragma warn .8017 void Log4cxxNonCppWrapper::trace( std::wstring message, int line, std::string function) { LOG4CXX_TRACE(this->logger, message); } Log4cxxNonCppWrapper log4cxxNonCppWrapper( log4cxxConfigDir + L"\\GosaPrint.exe.log4cxx.xml", L"GosaPrint.Main", __FILE__, __FUNC__); log4cxxNonCppWrapper.info(L"Programmstart: \"" + std::wstring(lpCmdLine) + L"\"", __LINE__); Mit freundlichen Grüßen, Thorsten Schöning -- Thorsten Schöning E-Mail:thorsten.schoen...@am-soft.de AM-SoFT IT-Systeme http://www.AM-SoFT.de/ Telefon...........05151- 9468- 55 Fax...............05151- 9468- 88 Mobil..............0178-8 9468- 04 AM-SoFT GmbH IT-Systeme, Brandenburger Str. 7c, 31789 Hameln AG Hannover HRB 207 694 - Geschäftsführer: Andreas Muchow