title: logback-classic SocketAppender and Lilith log viewer
body: <p>In a JEE6 project deployed in glassfish 3.1. I have the following issue: </p>
  
  <p>Lilith - a logviewer which listens to a socket - only catches the first log message then misses the rest of the messages. What makes it even worse is that the behavior is not consistent and occasionally it might catch the first and the third message. I can not find a pattern in the behavior, so any comments might help me find a way out!</p>
  
  <h3>Given logback.xml:</h3>
  
  <pre><code>    &lt;configuration scan="true" scanPeriod="3 seconds"&gt;
  
      &lt;statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener"/&gt;
  
      &lt;appender name="LogbackClassic" class="ch.qos.logback.classic.net.SocketAppender"&gt; 
          &lt;RemoteHost&gt;localhost&lt;/RemoteHost&gt; 
          &lt;Port&gt;4560&lt;/Port&gt; 
          &lt;ReconnectionDelay&gt;170&lt;/ReconnectionDelay&gt; 
          &lt;IncludeCallerData&gt;true&lt;/IncludeCallerData&gt; 
      &lt;/appender&gt;
  
      &lt;appender name="FILE"
            class="ch.qos.logback.core.rolling.RollingFileAppender"&gt;
          &lt;File&gt;log/prototype1.log&lt;/File&gt;
          &lt;rollingPolicy
          class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"&gt;
              &lt;FileNamePattern&gt;
                  logFile.%d{yyyy-MM-dd_HH-mm}.log.zip
              &lt;/FileNamePattern&gt;
          &lt;/rollingPolicy&gt;
          &lt;encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"&gt;
              &lt;Pattern&gt;
                  %d{HH:mm:ss.SSS} %-5p %F:%L %C %M %c - %m%n
              &lt;/Pattern&gt;
          &lt;/encoder&gt;
      &lt;/appender&gt;
  
      &lt;logger name="com.sam.prototype1" level="DEBUG"&gt; 
          &lt;appender-ref ref="FILE"/&gt;
          &lt;appender-ref ref="LogbackClassic"/&gt; 
      &lt;/logger&gt;
  
  &lt;/configuration&gt;
  </code></pre>
  
  <h3>And given the class:</h3>
  
  <pre><code>@RequestScoped
  @Named
  public class TimeProperty {
  
      @Inject
      private Date date;
      @Inject
      private SimpleDateFormat dateFormat;
      @Inject
      @LogbackLogger 
      private Logger logger;
  
      private String time;
  
      public String getTime() {
          return time;
      }
  
      public void setTime(String timeParam) {
          logger.debug("First log message ");
          dateFormat.applyPattern("HH:mm:ss:SSS");
          String tmp = dateFormat.format(date.getTime());
          logger.debug("Second log message: Logged time= "+tmp);
          time = tmp;
          logger.debug("Third log message: Logged time");
      }
      public void callSetTime(){
          setTime("Dummy parameter to avoid NULL in the test");
      }
  }
  </code></pre>
  
  <h3>which is triggered using the following jsf web page:</h3>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
      &lt;head&gt;
          &lt;title&gt;Time Page&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          #{timeProperty.callSetTime()}
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <h3>The file log/prototype1.log receives the following lines:</h3>
  
  <pre><code>17:40:45.479 DEBUG TimeProperty.java:38 com.sam.prototype1.modelentities.TimeProperty setTime com.sam.prototype1.modelentities.TimeProperty - First log message 
  17:40:45.498 DEBUG TimeProperty.java:41 com.sam.prototype1.modelentities.TimeProperty setTime com.sam.prototype1.modelentities.TimeProperty - Second log message: Logged time= 17:40:45:114
  17:40:45.499 DEBUG TimeProperty.java:44 com.sam.prototype1.modelentities.TimeProperty setTime com.sam.prototype1.modelentities.TimeProperty - Third log message: Logged time
  </code></pre>
  
  <h3>Meanwhile Lilith receives only the first message:</h3>
  
  <p><img src="https://i.stack.imgur.com/VSayw.jpg" alt="Lilith snapshot"></p>
  
  <h3>As an extra given for your convenience, here is the POM.xml:</h3>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
  &lt;groupId&gt;com.sam&lt;/groupId&gt;
  &lt;artifactId&gt;Prototype1&lt;/artifactId&gt;
  &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
  &lt;packaging&gt;war&lt;/packaging&gt;
  
  &lt;name&gt;Prototype1&lt;/name&gt;
  
  &lt;properties&gt;
      &lt;endorsed.dir&gt;${project.build.directory}/endorsed&lt;/endorsed.dir&gt;
      &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
  &lt;/properties&gt;
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
          &lt;artifactId&gt;slf4j-api&lt;/artifactId&gt;
          &lt;version&gt;1.7.5&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;ch.qos.logback&lt;/groupId&gt;
          &lt;artifactId&gt;logback-classic&lt;/artifactId&gt;
          &lt;version&gt;1.0.13&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;ch.qos.logback&lt;/groupId&gt;
          &lt;artifactId&gt;logback-core&lt;/artifactId&gt;
          &lt;version&gt;1.0.13&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax&lt;/groupId&gt;
          &lt;artifactId&gt;javaee-web-api&lt;/artifactId&gt;
          &lt;version&gt;6.0&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  
  &lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
              &lt;version&gt;3.1&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;source&gt;1.6&lt;/source&gt;
                  &lt;target&gt;1.6&lt;/target&gt;
                  &lt;compilerArguments&gt;
                      &lt;endorseddirs&gt;${endorsed.dir}&lt;/endorseddirs&gt;
                  &lt;/compilerArguments&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
  &lt;/project&gt;
  </code></pre>
  
  <h3>Needless to mention:</h3>
  
  <p>I also satisfied Glassfish requirement to add the following files to the domain classpath:
  jul-to-slf4j-1.7.5.jar and slf4j-api-1.7.5 and logback-core-1.0.13.jar and logback-classic-1.0.13.jar</p>