Dmitriy Goy
Dmitriy Goy

Reputation: 65

Springboot exception stacktrace logging

Im using springboot and wanna see stacktraces of my exception but i have no any idea why its not working I see only rows like this "2019-06-05 01:15:48.642 WARN 17372 --- [nio-8080-exec-1] .m.m.a.ExceptionHandlerExceptionResolver : Resolved [java.lang.NullPointerException]" without stacktrace or some usefull information

Ive already tried to change logger loglevels.

Ive no any specific log configurations.

some rows from gradle.build file

    ext {
        springBootVersion = '2.1.3.RELEASE'
    }
    repositories {
        maven {
            url "https://plugins.gradle.org/m2/"
        }
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
        classpath "gradle.plugin.com.boxfuse.client:gradle-plugin-publishing:5.2.4"
    }
}

apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-security'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'com.google.code.gson:gson:2.8.5'
    runtimeOnly 'org.springframework.boot:spring-boot-devtools'
}

I expect stacktrace for logged exception which i see

Upvotes: 1

Views: 1658

Answers (1)

Abhijit Sarkar
Abhijit Sarkar

Reputation: 24558

You may create a ControllerAdvice that logs all exceptions. See this article. https://medium.com/@jovannypcg/understanding-springs-controlleradvice-cd96a364033f

Upvotes: 1

Related Questions