I have troubles with having uncaught exceptions in the JSON logs. This is my logback-spring:
<!-- logback-spring.xml -->
<configuration>
<springProfile name="default">
<include resource="org/springframework/boot/logging/logback/base.xml"/>
</springProfile>
<springProfile name="prod">
<appender name="jsonConsoleAppender" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="net.logstash.logback.encoder.LogstashEncoder"/>
</appender>
<root level="INFO">
<appender-ref ref="jsonConsoleAppender"/>
</root>
</springProfile>
</configuration>
Let's have just null pointer exception in the controller:
@GetMapping("/user/userinfo")
public ResponseEntity<UserInfo> getUserInfo() {
throw new NullPointerException();
}
However, when logging to console I can see the uncaught exceptions but not in the JSON logger. JSON logger completely ignores this and then I cannot see it in Kibana.
EDIT: This seems to be problem only of IntelliJ! When running the jar file locally, the null pointer exception is correctly written to the log.