logback / LOGBACK-1716 [Open]
ServerSocketAppender doesn't work with 1.3.0+

==============================

Here's what changed in this issue in the last few minutes.
This issue has been created
This issue is now assigned to you.

View or comment on issue using this link
https://jira.qos.ch/browse/LOGBACK-1716

==============================
 Issue created
------------------------------

Grzegorz Grzybek created this issue on 07/Jan/23 11:29 AM
Summary:              ServerSocketAppender doesn't work with 1.3.0+
Issue Type:           Bug
Affects Versions:     1.3.5
Assignee:             Logback dev list
Components:           logback-classic
Created:              07/Jan/23 11:29 AM
Environment:
  I'm working on Pax Logging project which uses Logback (and Log4j2) as 
_logging backends_.
  
  Over time, we've collected quite a number of integration tests, which are 
quite tricky in OSGi environment, where Pax Exam testing framework itself 
relies on Pax Logging.
  
  However one of the tests stopped working when upgrading from SLF4J 1.7.36 + 
Logback 1.2.11 to SLF4J 2.0.6 + Logback 1.3.5.
  
  The configuration is:
  {code:xml}
  <configuration id="builtin.socket">
      <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
          <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
              <layout class="ch.qos.logback.classic.layout.TTLLLayout" />
          </encoder>
      </appender>
      <appender name="s" 
class="ch.qos.logback.classic.net.server.ServerSocketAppender">
          <address>localhost</address>
          <!-- System.setProperty("socketAppender.port", 
Integer.toString(port)); -->
          <port>${socketAppender.port}</port>
          <includeCallerData>true</includeCallerData>
      </appender>
      <logger name="my.logger" level="info" additivity="false">
          <appender-ref ref="s" />
      </logger>
      <root level="info">
          <appender-ref ref="console" />
      </root>
  </configuration>
  {code}
  
  The problem is 
https://github.com/qos-ch/logback/commit/fc7c9a440f560260c450cfe57e5f1a42b643a6a5
 commit, which changes 
{{ch.qos.logback.core.CoreConstants#SCHEDULED_EXECUTOR_POOL_SIZE}} from {{8}} 
to {{1}}.
  
  The problem is here:
  * {{ch.qos.logback.core.net.server.AbstractServerSocketAppender#start()}} 
creates an instance of 
{{ch.qos.logback.core.net.server.RemoteReceiverServerRunner}}
  * the runner is passed to scheduled executor taken from 
{{ch.qos.logback.core.Context#getExecutorService()}}
  * {{ch.qos.logback.core.net.server.ConcurrentServerRunner#run()}} running in 
executor's thread is this:
  {code:java}
  while (!Thread.currentThread().isInterrupted()) {
      T client = listener.acceptClient();
      if (!configureClient(client)) {
          addError(client + ": connection dropped");
          client.close();
          continue;
      }
      try {
          executor.execute(new ClientWrapper(client));
      } catch (RejectedExecutionException ex) {
          addError(client + ": connection dropped");
          client.close();
      }
  }
  {code}
  
  So every accepted client is passed to _the same executor_ as the server. It 
works only if the core pools size is greater than 1, because one thread is busy 
with the server itself. So the only thing that's happening is the growing queue 
of {{ch.qos.logback.core.net.server.ConcurrentServerRunner.ClientWrapper}} 
tasks.
  
  {{ch.qos.logback.core.CoreConstants#SCHEDULED_EXECUTOR_POOL_SIZE}} should be 
by default at least {{2}}.
Priority:             Major
Reporter:             Grzegorz Grzybek


==============================
 This message was sent by Atlassian Jira (v8.8.0#808000-sha1:e2c7e59)

_______________________________________________
logback-dev mailing list
logback-dev@qos.ch
https://mailman.qos.ch/cgi-bin/mailman/listinfo/logback-dev

Reply via email to