5

I have a web application deployed on GAE. I am using log4j2 implementation of SLF4j for logging purpose.

I can see all my logs on stackdriver console. But the level for all my logs is shown as info under stackdriver. It's not categorized properly based on the loglevel like debug, info, warning and error.

e.g. my log.error("error") is also displayed under info level in stackdriver console.

But when I use JUL implementation of SLF4 (slf4j-jdk14). All the logs are reported correctly with proper log level in stackdriver.

Can any one suggest what could be the issue?

Here is POM.

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.10.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <exclusions>
                <exclusion>
                  <groupId>org.springframework.boot</groupId>
                  <artifactId>spring-boot-starter-tomcat</artifactId>
          </exclusion>
          <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-logging</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>jul-to-slf4j</artifactId>
            </exclusion>
          </exclusions>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-log4j2</artifactId>
        <exclusions>
            <exclusion>
                <artifactId>tomcat-embed-logging-juli</artifactId>
                <groupId>org.apache.tomcat.embed</groupId>
            </exclusion>
            <exclusion>
                <artifactId>tomcat-embed-websocket</artifactId>
                <groupId>org.apache.tomcat.embed</groupId>
            </exclusion>
            <exclusion>
                <artifactId>tomcat-embed-el</artifactId>
                <groupId>org.apache.tomcat.embed</groupId>
            </exclusion>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>jul-to-slf4j</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
          <groupId>javax.servlet</groupId>
          <artifactId>javax.servlet-api</artifactId>
          <version>3.1.0</version>
          <scope>provided</scope>
  </dependency>

</dependencies>

I have captured the screenshot of log4j2 and logback implementation where level is not shown correctly

enter image description here

enter image description here

Yogesh
  • 773
  • 1
  • 8
  • 22
  • Did you ever find a solution to this? – Niel de Wet Nov 05 '18 at 12:19
  • Please check ... https://stackoverflow.com/questions/37420400/how-do-i-map-my-java-app-logging-events-to-corresponding-cloud-logging-event-lev#39779646 – Yogesh Nov 12 '18 at 10:06
  • you can follow the below steps level>WARN %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} %M - %msg%n And then create the GCPCloudLoggingJSONLayout as given in the above link – Yogesh Nov 12 '18 at 10:09

0 Answers0