<configuration>
    <appender name="Loki" class="pl.tkowalcz.tjahzi.logback.LokiAppender">
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>INFO</level>
        </filter>
        <url>${loki_push_url:- }</url>
        <encoder>
            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %p [${HOSTNAME}] [%t] %logger #@# %m%n%ex{full}</pattern>
        </encoder>
        <label>
            <name>app</name>
            <value>hudi-${run_type:- }</value>
        </label>
        <label>
            <name>host</name>
            <value>${HOSTNAME}</value>
        </label>
        <label>
            <name>run_type</name>
            <value>${run_type:- }</value>
        </label>
        <label>
            <name>flink_job_id</name>
            <value>${flink_job_id:- }</value>
        </label>
        <label>
            <name>flink_job_name</name>
            <value>${flink_job_name:- }</value>
        </label>
        <label>
            <name>schema</name>
            <value>${schema:- }</value>
        </label>
        <label>
            <name>table</name>
            <value>${table:- }</value>
        </label>
        <label>
            <name>batch_id</name>
            <value>${batch_id:- }</value>
        </label>
        <label>
            <name>alias</name>
            <value>${alias:- }</value>
        </label>
        <label>
            <name>app_id</name>
            <value>${_APP_ID:- }</value>
        </label>
        <label>
            <name>container_id</name>
            <value>${CONTAINER_ID:- }</value>
        </label>
        <logLevelLabel>level</logLevelLabel>
    </appender>

    <appender name="File" class="ch.qos.logback.core.FileAppender">
        <file>run.log</file>
        <append>false</append>
        <encoder>
            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %p [${HOSTNAME}] [%t] %logger #@# %m%n%ex{full}</pattern>
        </encoder>
    </appender>

    <appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %p [${HOSTNAME}] [%t] %logger #@# %m%n%ex{full}</pattern>
        </encoder>
    </appender>

    <root level="INFO">
        <appender-ref ref="Loki"/>
        <appender-ref ref="File"/>
        <appender-ref ref="Console"/>
    </root>

    <logger name="org.apache.hadoop.conf.Configuration" level="ERROR"/>
    <logger name="org.apache.hadoop.util.NativeCodeLoader" level="ERROR"/>
    <logger name="org.apache.hadoop.hdfs.shortcircuit.DomainSocketFactory" level="ERROR"/>
    <logger name="akka" level="ERROR"/>
    <logger name="org.apache.flink.runtime" level="ERROR"/>
    <logger name="org.apache.flink.runtime.taskexecutor.TaskExecutor" level="WARN"/>
    <logger name="org.apache.flink.core.plugin.PluginConfig" level="ERROR"/>

    <logger name="org.apache.hudi" level="INFO"/>
    <logger name="com.eshore.odcp.hudi.connector.sync" level="INFO"/>
</configuration>