Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a Custom Logger #7

Open
2 tasks
ChakshuGautam opened this issue Aug 9, 2021 · 1 comment
Open
2 tasks

Create a Custom Logger #7

ChakshuGautam opened this issue Aug 9, 2021 · 1 comment

Comments

@ChakshuGautam
Copy link
Contributor

ChakshuGautam commented Aug 9, 2021

Create a custom logger which can replace the existing Lombok, Sl4j log and can push logs as a stream to Kafka. See this.

  1. Since the logger would mostly be a configuration log42j.xml in spring, try to inject is using Utils to all the other repos.
  2. The library to use -> https://logging.apache.org/log4j/2.x/manual/appenders.html#KafkaAppender
  3. The third step would be to send these to Sunbird Telemetry Service. So telemetry object creation to be part of Utils service. See spec here

Tasks

  • Create a generic Log object from the spec in JSON
  • Update the logger to send generic objects to kafka. This needs to be an async appender.
@surabhi-mahawar
Copy link
Contributor

surabhi-mahawar commented Aug 10, 2021

This is the xml file I am using for sending logs to kafka

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="info" name="spring-boot-kafka-log">
	<Properties>
		<Property name="kafka.topic">${env:KAFKA_LOGS_TOPIC}</Property>
		<Property name="kafka.bootstrap.servers">${env:BOOTSTRAP_SERVERS}</Property>
	</Properties>
	<Appenders>
		<Kafka name="KafkaLogAppender" topic="${kafka.topic}">
			<JSONLayout />
			<!--  <PatternLayout pattern="%date %message"/>  -->
			<Property name="bootstrap.servers">${kafka.bootstrap.servers}</Property>
		</Kafka>

		<Console name="stdout" target="SYSTEM_OUT">
			<PatternLayout
				pattern="%d{HH:mm:ss.SSS} stdout %highlight(%-5p) [%-7t] %F:%L - %m%n" />
		</Console>
		
		<Console name="stderr" target="SYSTEM_OUT">
			<PatternLayout
				pattern="%d{HH:mm:ss.SSS} stderr %highlight(%-5p) [%-7t] %F:%L - %m%n" />
		</Console>

	</Appenders>
	<Loggers>
		<Root level="INFO">
			<AppenderRef ref="KafkaLogAppender" />
			<AppenderRef ref="stdout" />
			<AppenderRef ref="stderr" />
		</Root>
		<Logger name="org.apache.kafka" level="WARN" />
	</Loggers>
</Configuration>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants