0

I would like to create a custom LogBack Appender for InfluxDB. For that, I want to define many series and use the power of logback

<appender name="INFLUXDB" class="org.labaix.logback.InfluxDbAppender">
   <series>
     <serie>
        <id>SensorTemperatureMonthly</id>
        <name>machine.%X{machine}.type.%X{type} temperature_${byMonth}</name>
        <timeUnit>MILLISECONDS</timeUnit>
     </serie>
     <serie>
        <id>SensorTemperatureDaily</id>
        <name>machine.%X{machine}.type.%X{type} temperature_${day}</name>
        <timeUnit>MILLISECONDS</timeUnit>
     </serie>
   </series>
</appender>

Therefore I don't know how to map list of series. Any ideas ? It is not in documentation so I wonder if it possible.

Thanks. Best regards Nicolas

2 Answers2

0

Rather than this approach I would prefer to use xml and use JAXB object to load data. You can pass the configuration file xml path as an parameter

<appender name="INFLUXDB" class="org.labaix.logback.InfluxDbAppender">
   <configFilePath>configFilePath.xml</configFilePath>
</appender>

The configuration file

<root>
  <series>
     <serie>
        <id>SensorTemperatureMonthly</id>
        <name>machine.%X{machine}.type.%X{type} temperature_${byMonth}</name>
        <timeUnit>MILLISECONDS</timeUnit>
     </serie>
     <serie>
        <id>SensorTemperatureDaily</id>
        <name>machine.%X{machine}.type.%X{type} temperature_${day}</name>
        <timeUnit>MILLISECONDS</timeUnit>
     </serie>
   </series>
</root>
Karthik Prasad
  • 9,662
  • 10
  • 64
  • 112
0

I hit the same problem. I found the answer in ch.qos.logback.core.joran.util.beans.BeanDescription

/**
 * Lightweight pendant to the java.beans.BeanInfo class. An instance of this
 * class encapsulates the properties of a certain class. The properties are the
 * public setters and getters. In addition the 'add-er'-methods are included,
 * which are the public methods which start with the prefix 'add'.
 *
 * @author urechm
 *
 */

In this case you could use an addSerie method that adds to a mutable list

Toddy
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 21 '22 at 12:15