aliyun / aliyun-log-logback-appender

Apache License 2.0
186 stars 64 forks source link

SpringBoot print "Process finished with exit code 0" after declare Aliyun Appender in xml #23

Open thkdog opened 4 years ago

thkdog commented 4 years ago

Everything works fine before adding "aliyun" appender. I'm using Spring Boot with version '2.2.2.RELEASE'. When adds this appender, the output shows 'Process finished with exit code 0' directly without any error output. I have totally no idea what's wrong with the configuration. Things go back to normal if removing the appender declare.

logback-spring.xml

<configuration>
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <!-- encoders are assigned the type
             ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
        <encoder>
            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>
    </appender>

    <appender name="aliyun" class="com.aliyun.openservices.log.logback.LoghubAppender">
        <!-- Required parameters -->
        <!-- Configure account and network  -->
        <endpoint>cn-shanghai-intranet.log.aliyuncs.com</endpoint>
        <accessKeyId>xxx</accessKeyId>
        <accessKeySecret>xxx</accessKeySecret>

        <project>edcs</project>
        <logStore>edcs-api-service</logStore>

        <!-- Configure sls -->
<!--        <springProfile name="daily">-->
<!--            <project>edcs</project>-->
<!--            <logStore>edcs-api-service</logStore>-->
<!--        </springProfile>-->
<!--        <springProfile name="prod">-->
<!--            <project>edcs</project>-->
<!--            <logStore>edcs-api-service</logStore>-->
<!--        </springProfile>-->
        <!-- Required parameters(end) -->

        <!-- Optional parameters -->
<!--        <topic>your topic</topic>-->
<!--        <source>your source</source>-->

        <!-- Optional parameters -->
        <totalSizeInBytes>104857600</totalSizeInBytes>
        <maxBlockMs>60000</maxBlockMs>
        <ioThreadCount>8</ioThreadCount>
        <batchSizeThresholdInBytes>524288</batchSizeThresholdInBytes>
        <batchCountThreshold>4096</batchCountThreshold>
        <lingerMs>2000</lingerMs>
        <retries>10</retries>
        <baseRetryBackoffMs>100</baseRetryBackoffMs>
        <maxRetryBackoffMs>100</maxRetryBackoffMs>

        <!-- Optional parameters -->
        <encoder>
            <pattern>%d %-5level [%thread] %logger{0}: %msg</pattern>
        </encoder>

        <!--  Optional parameters -->
        <timeFormat>yyyy-MM-dd'T'HH:mmZ</timeFormat>
        <!--  Optional parameters -->
        <timeZone>Asia/Shanghai</timeZone>
    </appender>

    <shutdownHook class="ch.qos.logback.core.hook.DelayingShutdownHook"/>
    <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener"/>

    <root level="debug">
        <appender-ref ref="STDOUT" />
        <appender-ref ref="aliyun" />
    </root>

    <springProfile name="default">
        <root level="debug">
            <appender-ref ref="STDOUT" />
            <appender-ref ref="aliyun" />
        </root>
        <logger name="org.hibernate.SQL" level="info"/>
        <logger name="org.hibernate.type" level="trace"/>
    </springProfile>

    <springProfile name="daily">
        <root level="debug">
            <appender-ref ref="STDOUT" />
        </root>
        <logger name="org.hibernate.SQL" level="info"/>
        <logger name="org.hibernate.type" level="trace"/>
    </springProfile>

    <springProfile name="prod">
        <root level="info">
            <appender-ref ref="STDOUT" />
        </root>
    </springProfile>
</configuration>
thkdog commented 4 years ago

Here is my pom, it's really simple. I've check the conflicts and there's nothing need to worry about.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.2.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>cn.xxxx</groupId>
    <artifactId>edcs-api-service</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>edcs-api-service</name>
    <description></description>

    <properties>
        <java.version>11</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
        </dependency>
        <dependency>
            <groupId>com.auth0</groupId>
            <artifactId>java-jwt</artifactId>
            <version>3.8.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
            <version>1.1.21</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.restdocs</groupId>
            <artifactId>spring-restdocs-mockmvc</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.10.1</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>com.vladmihalcea</groupId>
            <artifactId>hibernate-types-52</artifactId>
            <version>2.4.3</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-spatial</artifactId>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.7.0</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.7.0</version>
        </dependency>
        <dependency>
            <groupId>com.googlecode.xmemcached</groupId>
            <artifactId>xmemcached</artifactId>
            <version>2.4.6</version>
        </dependency>
        <dependency>
            <groupId>com.aliyun.oss</groupId>
            <artifactId>aliyun-sdk-oss</artifactId>
            <version>3.8.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.9</version>
        </dependency>
        <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib</artifactId>
            <version>3.3.0</version>
        </dependency>
        <dependency>
            <groupId>org.modelmapper</groupId>
            <artifactId>modelmapper</artifactId>
            <version>2.3.0</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.protobuf</groupId>
            <artifactId>protobuf-java</artifactId>
            <version>2.5.0</version>
        </dependency>
        <dependency>
            <groupId>com.aliyun.openservices</groupId>
            <artifactId>aliyun-log-logback-appender</artifactId>
            <version>0.1.15</version>
        </dependency>
    </dependencies>

    <build>
        <finalName>app</finalName>
        <plugins>
            <plugin>
                <groupId>org.asciidoctor</groupId>
                <artifactId>asciidoctor-maven-plugin</artifactId>
                <version>1.5.8</version>
                <executions>
                    <execution>
                        <id>generate-docs</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>process-asciidoc</goal>
                        </goals>
                        <configuration>
                            <backend>html</backend>
                            <doctype>book</doctype>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.springframework.restdocs</groupId>
                        <artifactId>spring-restdocs-asciidoctor</artifactId>
                        <version>${spring-restdocs.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>com.smartnews</groupId>
                <artifactId>maven-jpa-entity-generator-plugin</artifactId>
                <version>0.99.8</version>
                <dependencies>
                    <dependency>
                        <groupId>mysql</groupId>
                        <artifactId>mysql-connector-java</artifactId>
                        <version>5.1.46</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>
</project>
thkdog commented 4 years ago

Problem solved. I upgrade springfox-swagger2 from 2.7.0 to 2.9.2, then the problem solved, although the guava still exists conflicts. It's because grava have conflicts between swagger and aliyun-appender. I found this error because I added <include resource="org/springframework/boot/logging/logback/base.xml"/> code to logback-spring.xml, then the error shows.