Details
Description
I upgraded from log4cxx 0.10.0.1 to 0.12.1.0 on Windows and get this debug assertion when logging a string larger than the MaxMessageLength using a SyslogAppender.
In Release mode the string is logged correctly and split up into multiple log messages of length MaxMessageLength.
Version 0.12.1 built in x86 with vcpkg on Windows using Visual Studio 2022 17.2.2. 0.13.0 is not yet available from vcpkg but I can't see any commits that would change this behaviour.
Code to reproduce:
#include "log4cxx/logger.h" #include "log4cxx/xml/domconfigurator.h" int main(void) { log4cxx::xml::DOMConfigurator::configure("log4cxx.xml"); log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger("main")); LOG4CXX_ERROR(logger, "aaaaaaaa"); auto rootlogger = log4cxx::Logger::getRootLogger(); auto appender = rootlogger->getAppender(LOG4CXX_STR("ASYNC")); if (appender != nullptr) { appender->close(); } }
log4cxx.xml
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> <log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'> <appender name="SYSLOG" class="org.apache.log4j.SyslogAppender"> <param name="Threshold" value="INFO" /> <param name="SysLogHost" value="localhost" /> <param name="Facility" value="DAEMON" /> <param name="MaxMessageLength" value="10" /> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%d %-5p - %m%n" /> </layout> </appender> <appender name="ASYNC" class="org.apache.log4j.AsyncAppender"> <param name="BufferSize" value="500"/> <param name="Blocking" value="true"/> <param name="LocationInfo" value="true"/> <appender-ref ref="SYSLOG"/> </appender> <root> <level value="INFO"/> <appender-ref ref="ASYNC" /> </root> </log4j:configuration>
The workaround is to increase MaxMessageLength as much as necessary.