danielpetri opened a new issue, #3211:
URL: https://github.com/apache/logging-log4j2/issues/3211

   ## Description
   
   Log4cxx 1.1.0 (default available on Ubuntu 24.04) does not close file 
descriptors when the log server, e.g., chainsaw is not running. The counting 
number of sockets remain open.
   
   Code example:
   ```
   #include <memory>
   #include <log4cxx/patternlayout.h>
   #include <log4cxx/net/xmlsocketappender.h>
   #include <thread>
   
   int main( int argc, char *argv[] )
   {
       auto logger = log4cxx::Logger::getRootLogger( );
       auto appender = std::make_shared<log4cxx::net::XMLSocketAppender>( 
"localhost", 1234 );
       auto layout =
           std::make_shared<log4cxx::PatternLayout>( LOG4CXX_STR( "[%-4p] 
(%F:%L) %d{mm:ss,SSS} %X{application} %m%n" ) );
       appender->setLayout( layout );
       log4cxx::helpers::Pool pool;
       appender->activateOptions( pool );
       logger->addAppender( appender );
       logger->setLevel( log4cxx::Level::getInfo( ) );
   
       while ( true )
       {
           LOG4CXX_ERROR( logger, "Something went wrong" );
           LOG4CXX_INFO( logger, "Very important information" );
           std::this_thread::sleep_for( std::chrono::seconds( 1 ) );
       }
   
       return 0;
   }
   ```
   
   Listing and counting the open file descriptors periodically results in a 
constantly growing number:
   ```
   # ls -l /proc/$(pidof log4cxxdemo)/fd | wc -l
   123
   # sleep 600
   # ls -l /proc/$(pidof log4cxxdemo)/fd | wc -l
   141
   ```
   The socket should be closed after connection failures.
   
   ## Configuration
   
   **Version:** [Log4cxx 1.1.0]
   
   **Operating system:** [Linux, Ubuntu 24.04]
   
   ## Logs
   
   Program output
   ```
   log4cxx: Could not connect to [localhost:1234]. We will try again in 30000 ms
   log4cxx: IO Exception : status code = 111(Connection refused)
   ```
   
   ## Reproduction
   Compile the code above and link with log4cxx library, then execute.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@logging.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to