Announcement Announcement Module
Collapse
No announcement yet.
Remote chunking - different log files for master and slave Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Remote chunking - different log files for master and slave

    Hi,

    I'm using logback and slf4j. This is my current configuration (logback.xml):

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <configuration debug="false">
        
      <!-- Console -->  
      <appender name="S" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
          <pattern>%d{yyyy-MM-dd HH:mm:ss} %c{1} [%p] %m%n</pattern>
        </encoder>
      </appender>
      
      <!-- HTML Rolling Appender -->
      <appender name="H" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>logs/subscription-server.log.html</file>
        <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
            <layout class="ch.qos.logback.classic.html.HTMLLayout">
                <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS} %5p - %m %c %n</pattern>
            </layout>
        </encoder>
        <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
          <fileNamePattern>logs/subscription-server.log.html.%i</fileNamePattern>
          <minIndex>1</minIndex>
          <maxIndex>3</maxIndex>
        </rollingPolicy>
        <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
          <MaxFileSize>1024KB</MaxFileSize>
        </triggeringPolicy>
      </appender>
      
      <!-- Plain Text Rolling Appender -->
      <appender name="R" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <Append>true</Append>
        <File>logs/subscription-server.log</File>
        <encoder>
          <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS} %5p - %m %c %n</pattern>
        </encoder>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
          <fileNamePattern>logs/subscription-server.log.%d{yyyy-MM-dd}</fileNamePattern>
          <maxHistory>30</maxHistory>
        </rollingPolicy>
      </appender>
      
      <logger name="org.w3c.tidy" level="OFF"/>
      <logger name="ch.qos" level="OFF"/>
      <logger name="org.slf4j" level="OFF"/>
      <logger name="com.m4u" level="DEBUG"/>
      <logger name="net.sf" level="DEBUG"/>
      <logger name="org.springframework.integration" level="DEBUG"/>
      <logger name="org.springframework.batch.integration" level="DEBUG"/>
      <logger name="org.springframework.jms" level="DEBUG"/>
      <logger name="org.springframework.batch.item.database" level="DEBUG"/>
      
    
      <root level="WARN">
        <appender-ref ref="S"/>
        <appender-ref ref="H"/>
        <appender-ref ref="R"/>
      </root>
    </configuration>
    With this configuration, both master and slave nodes write to the same log file (in this case "logs/subscription-server.log").
    I want them to have their own log file. For example, "subscription-master.log" for master and "subscription-slave.log" for slave nodes. How can I do that?

    Thanks!

  • #2
    Add in a logger and file appender for your remote slave API.

    <!-- Logs out to a file on the file system. Archiving is automatic. -->
    <appender name="SLAVE-FILE" class="ch.qos.logback.core.rolling.RollingFileAppe nder">
    <Append>true</Append>
    <File>logs/slave-subscription-server.log</File>
    <encoder>
    <pattern>%d{dd/MMM/yyyy HH:mm:ss,SSS} %5p - %m %c %n</pattern>
    </encoder>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollin gPolicy">
    <fileNamePattern>logs/subscription-server.log.%d{yyyy-MM-dd}</fileNamePattern>
    <maxHistory>30</maxHistory>
    </rollingPolicy>
    </appender>

    <logger name="my.remote.logger.api..." level="DEBUG">
    <appender-ref ref="SLAVE-FILE">
    </logger>

    Logging statements within the api my.remote.logger.api... will be captured by this new logger and recored using the new appender.

    Hope this helps,

    Jeff

    Comment


    • #3
      Thank you Jeff!

      Comment

      Working...
      X