danielwegener / logback-kafka-appender

Logback appender for Apache Kafka
Apache License 2.0
640 stars 263 forks source link

AutoScan not working with Appender properties #37

Open VidhyaKailash opened 7 years ago

VidhyaKailash commented 7 years ago

I am trying to use the TurboFiltercalled ReconfigureOnChangeFilter to change the properties of appender like broker and topic and they wouldnt take effect with the KafkaAppender. http://logback.qos.ch/manual/configuration.html#autoScan

Can somebody please point me to how I can implement this quickly for the Kafka Appender. We have an environment where we might need to change the brokers or topicname maybe not so frequently, but preferably without restarting the server. thanks Vidhya
danielwegener commented 7 years ago

I am not really sure how the ReconfigureOnChangeFilter works, i.e. if if really reinitializes the logging context using reset (in that case, the kafka appender should naturally work) or if it simply reapplies all properties to the existing appender. It the latter case what could probably make it work would be to trigger a producer reinitialization on each producer configuration change (e.g. in com.github.danielwegener.logback.kafka.KafkaAppenderConfig#addProducerConfigValue). But since these changes are not all applied at once but one after another while joran fires its sax event listeners one would have to debounce the automatic appender reconfiguration. It would also be a clever idea to keep the old producer running until the new producer has collected meta data and is ready to deliver.

danielwegener commented 7 years ago

Just dived into the code. A simple reset is not enough since it just stops all appenders but does not restart them. To reload the kafka producer, the whole configuration has to be reinitialized (using the JoranConfigurer path).