Thank you very much! On Sun, Aug 15, 2021, 19:05 Robert Middleton <osfan6...@gmail.com> wrote:
> Technical reason: > Since the new version of log4cxx uses std::shared_ptr(instead of the > homegrown smart pointer solution), you need to slightly modify your code to > work. The reason for the shared_ptr is that it's standard, and it fixes > some bugs with regards to reference counting. The original homegrown > solution was implicitly convertible to/from a pointer; shared_ptr is not. > > Create a typedef for your appender using the LOG4CXX_PTR_DEF macro: > > LOG4CXX_PTR_DEF(ROSConsoleStdioAppender) > > Then just create a new shared_ptr with your typedef: > > ROSConsoleStdioAppenderPtr(new ROSConsoleStdioAppender()); > > -Robert Middleton > > On Sun, Aug 15, 2021 at 5:37 AM Achmad Fathoni <fathoni...@gmail.com> > wrote: > >> This sample program can be compiled with 0.11.0 but not 0.12.0. The error >> is "Cannot convert ‘ROSConsoleStdioAppender*’ to ‘log4cxx::App >> enderPtr’ {aka ‘std::shared_ptr<log4cxx::Appender>’}". What change do I >> need to make it works with 0,12.0? Thank you. >> >> #include <log4cxx/log4cxx.h> >> #include <log4cxx/basicconfigurator.h> >> #include <log4cxx/helpers/exception.h> >> #include <log4cxx/logger.h> >> #include <log4cxx/level.h> >> #include <log4cxx/appenderskeleton.h> >> >> using namespace log4cxx; >> using namespace log4cxx::helpers; >> >> class ROSConsoleStdioAppender : public log4cxx::AppenderSkeleton >> { >> public: >> ~ROSConsoleStdioAppender() >> { >> } >> >> protected: >> virtual void append(const log4cxx::spi::LoggingEventPtr& event, >> log4cxx::helpers::Pool&) >> { >> } >> >> virtual void close() >> { >> } >> >> virtual bool requiresLayout() const >> { >> return false; >> } >> }; >> >> int main(){ >> LoggerPtr logger(Logger::getLogger("main")); >> logger->addAppender(new ROSConsoleStdioAppender); >> return 0; >> } >> >