diff --git a/src/main/include/log4cxx/levelchange.h b/src/main/include/log4cxx/levelchange.h index df2f6f965..1a5ec5737 100644 --- a/src/main/include/log4cxx/levelchange.h +++ b/src/main/include/log4cxx/levelchange.h @@ -52,7 +52,7 @@ namespace LOG4CXX_NS } /// Set \c otherCategory to the level of \c thisCategory LevelChange(const LoggerPtr& otherCategory, const LoggerPtr& thisCategory) - : LevelChange(otherCategory, m_otherCategory->getLevel()) + : LevelChange(otherCategory, thisCategory->getLevel()) { } /// Set the logger named \c otherCategory to \c level diff --git a/src/test/cpp/levelchangetestcase.cpp b/src/test/cpp/levelchangetestcase.cpp index 85ea1eb2c..c935d9305 100644 --- a/src/test/cpp/levelchangetestcase.cpp +++ b/src/test/cpp/levelchangetestcase.cpp @@ -124,12 +124,22 @@ LOGUNIT_CLASS(LevelChangeTestCase) processor.DoStep1(); LOGUNIT_ASSERT_EQUAL(appender->count, initialCount); { - LevelChange x(LOG4CXX_STR("ComplexProcessing"), myLogger); + LevelChange ctx(getLogger(LOG4CXX_STR("ComplexProcessing")), myLogger); processor.DoStep2(); // Check the ComplexProcessing debug request was sent to the appender LOGUNIT_ASSERT_EQUAL(appender->count, initialCount + 1); } + // Check the ComplexProcessing debug request is not sent to the appender + processor.DoStep1(); + LOGUNIT_ASSERT_EQUAL(appender->count, initialCount + 1); + { + LevelChange ctx(LOG4CXX_STR("ComplexProcessing"), myLogger); + processor.DoStep2(); + // Check the ComplexProcessing debug request was sent to the appender + LOGUNIT_ASSERT_EQUAL(appender->count, initialCount + 2); + } + // Check the ComplexProcessing debug request is no longer sent to the appender auto finalCount = appender->count; processor.DoStep3();