Skip to content

Commit

Permalink
Issue #TG-377 feat: added logback.xml (#1736)
Browse files Browse the repository at this point in the history
  • Loading branch information
AMIT KUMAR authored Jul 17, 2020
1 parent 2d51cbb commit 9d08bcb
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 4 deletions.
4 changes: 3 additions & 1 deletion ansible/roles/stack-sunbird/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,9 @@ sunbird_portal_player_cdn_enabled: false
sunbird_cert_qr_container_name: "certqr"

service_env:
learner: ../../../../ansible/roles/stack-sunbird/templates/sunbird_learner-service.env
learner:
- ../../../../ansible/roles/stack-sunbird/templates/sunbird_learner-service.env
- ../../../../ansible/roles/stack-sunbird/templates/learner-service_logback.xml
lms:
- ../../../../ansible/roles/stack-sunbird/templates/sunbird_lms-service.env
- ../../../../ansible/roles/stack-sunbird/templates/lms-service_logback.xml
Expand Down
92 changes: 92 additions & 0 deletions ansible/roles/stack-sunbird/templates/learner-service_logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<configuration>

<conversionRule conversionWord="coloredLevel" converterClass="play.api.libs.logback.ColoredLevel" />

<!-- transaction-event-trigger START -->
<timestamp key="timestamp" datePattern="yyyy-MM-dd"/>
<!-- common transactions logs -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d %msg%n</pattern>
</encoder>
</appender>

<appender name="ASYNCSTDOUT" class="ch.qos.logback.classic.AsyncAppender">
<appender-ref ref="STDOUT" />
</appender>


<logger name="play" level="INFO" />
<logger name="DefaultPlatformLogger" level="INFO" />
<!-- Telemetry Loggers-->

<root level="INFO">
<appender-ref ref="ASYNCSTDOUT" />
</root>


<appender name="kafka-appender" class="com.github.danielwegener.logback.kafka.KafkaAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%msg</pattern>
</encoder>

<topic>${ENV_NAME}.telemetry.raw</topic>
<!-- ensure that every message sent by the executing host is partitioned to the same partition strategy -->
<keyingStrategy class="com.github.danielwegener.logback.kafka.keying.NoKeyKeyingStrategy" />
<!-- block the logging application thread if the kafka appender cannot keep up with sending the log messages -->
<deliveryStrategy class="com.github.danielwegener.logback.kafka.delivery.AsynchronousDeliveryStrategy" />

<!-- each <producerConfig> translates to regular kafka-client config (format: key=value) -->
<!-- producer configs are documented here: https://kafka.apache.org/documentation.html#newproducerconfigs -->
<!-- bootstrap.servers is the only mandatory producerConfig -->
<producerConfig>bootstrap.servers=${SUNBIRD_KAFKA_URL}</producerConfig>
<!-- don't wait for a broker to ack the reception of a batch. -->
<producerConfig>acks=0</producerConfig>
<!-- wait up to 1000ms and collect log messages before sending them as a batch -->
<producerConfig>linger.ms=15000</producerConfig>
<!-- even if the producer buffer runs full, do not block the application but start to drop messages -->
<producerConfig>max.block.ms=0</producerConfig>
<!-- define a client-id that you use to identify yourself against the kafka broker -->
<producerConfig>client.id=${HOSTNAME}-${CONTEXT_NAME}-logback-relaxed</producerConfig>

<!-- there is no fallback <appender-ref>. If this appender cannot deliver, it will drop its messages. -->

</appender>

<appender name="context-log-kafka-appender" class="com.github.danielwegener.logback.kafka.KafkaAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%msg</pattern>
</encoder>

<topic>${ENV_NAME}.db.query.events</topic>
<!-- ensure that every message sent by the executing host is partitioned to the same partition strategy -->
<keyingStrategy class="com.github.danielwegener.logback.kafka.keying.NoKeyKeyingStrategy" />
<!-- block the logging application thread if the kafka appender cannot keep up with sending the log messages -->
<deliveryStrategy class="com.github.danielwegener.logback.kafka.delivery.AsynchronousDeliveryStrategy" />

<!-- each <producerConfig> translates to regular kafka-client config (format: key=value) -->
<!-- producer configs are documented here: https://kafka.apache.org/documentation.html#newproducerconfigs -->
<!-- bootstrap.servers is the only mandatory producerConfig -->
<producerConfig>bootstrap.servers=${SUNBIRD_KAFKA_URL}</producerConfig>
<!-- don't wait for a broker to ack the reception of a batch. -->
<producerConfig>acks=0</producerConfig>
<!-- wait up to 1000ms and collect log messages before sending them as a batch -->
<producerConfig>linger.ms=15000</producerConfig>
<!-- even if the producer buffer runs full, do not block the application but start to drop messages -->
<producerConfig>max.block.ms=0</producerConfig>
<!-- define a client-id that you use to identify yourself against the kafka broker -->
<producerConfig>client.id=${HOSTNAME}-${CONTEXT_NAME}-logback-relaxed</producerConfig>

<!-- there is no fallback <appender-ref>. If this appender cannot deliver, it will drop its messages. -->

</appender>

<logger name="TelemetryEventLogger" level="INFO">
<appender-ref ref="kafka-appender" />
</logger>

<logger name="ContextEventLogger" level="DEBUG">
<appender-ref ref="context-log-kafka-appender" />
</logger>

</configuration>
14 changes: 11 additions & 3 deletions kubernetes/helm_charts/core/learner/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,25 @@ spec:
readinessProbe:
{{ toYaml .Values.readinessProbe | indent 10 }}
{{- end }}
volumeMounts:
- name: {{ .Chart.Name }}-xml-config
mountPath: /home/sunbird/learner/learning-service-1.0-SNAPSHOT/config/logback.xml
subPath: learner-service_logback.xml
{{- $keys := .Files.Glob "keys/*" }}
{{- if $keys }}
volumeMounts:
- mountPath: {{ .Values.learner_device_basepath }}
name: access-keys
{{- end }}
volumes:
- name: {{ .Chart.Name }}-xml-config
configMap:
name: {{ .Chart.Name }}-xml-config
{{- $keys := .Files.Glob "keys/*" }}
{{- if $keys }}
- name: access-keys
secret:
secretName: learner-access-keys
{{ end }}

{{- end }}
---
apiVersion: v1
kind: Service
Expand Down

0 comments on commit 9d08bcb

Please sign in to comment.