Uploaded image for project: 'Log4cxx'
  1. Log4cxx
  2. LOGCXX-556

Debug assertion in runtime library when logging string larger than MaxMessageLength and using a SyslogAppender

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 0.12.1
    • 0.13.1
    • Appender
    • None
    • Windows MSVC 17.2.2 x86

    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.

       

      Attachments

        1. image-2022-06-01-13-24-05-356.png
          17 kB
          Michael Gibbs
        2. image-2022-06-01-13-30-25-208.png
          124 kB
          Michael Gibbs
        3. image-2022-06-01-13-31-27-072.png
          80 kB
          Michael Gibbs

        Activity

          People

            rmiddleton Robert Middleton
            michaelgibbs Michael Gibbs
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: