mycontroller-org / mycontroller-v1-legacy

The Open Source Controller
http://www.MyController.org
Apache License 2.0
148 stars 89 forks source link

Add raw logs from gateway in a file #473

Closed jkandasa closed 6 years ago

jkandasa commented 6 years ago

add raw logs from the gateway in a file. will be used for debugging purpose

jkandasa commented 6 years ago

enable raw message debugging in mycontroller/conf/logback.xml, by default this logger will be in INFO mode. change it to level="DEBUG"

  <logger name="RAW_MESSAGE_LOGGER" level="DEBUG" additivity="false">
    <appender-ref ref="GATEWAY_RAW_MESSAGE_APPENDER" />
  </logger>

  <appender name="GATEWAY_RAW_MESSAGE_APPENDER" class="ch.qos.logback.classic.sift.SiftingAppender">
    <discriminator>
      <key>gateway_reference</key>
      <defaultValue>0_default</defaultValue>
    </discriminator>
    <sift>
      <appender name="fileAppender" class="ch.qos.logback.core.FileAppender">
        <file>../logs/raw_message_gw_${gateway_reference}.log</file>
        <encoder>
          <pattern>%date %replace(%replace(%msg){'\r', '\\r'}){'\n', '\\n'}%n</pattern>
        </encoder>
        <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
          <FileNamePattern>../logs/raw_message_gw_${gateway_reference}%i.log.zip</FileNamePattern>
          <MinIndex>1</MinIndex>
          <MaxIndex>5</MaxIndex>
        </rollingPolicy>
        <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
          <MaxFileSize>5MB</MaxFileSize>
        </triggeringPolicy>
      </appender>
    </sift>
  </appender>

Actual file: https://github.com/mycontroller-org/mycontroller/blob/development/dist/src/main/package/conf/logback.xml You will get debug logs on mycontroller/logs/raw_message_gw_*.log.