Hi I have a multimodule springboot based project and I would like to keep logging separate for each module. I am using tiny log 2, but the issue I am facing is that, when there is a stack trace thrown, it is not getting captured in my rolling log file. Here is the tinyLog configuration:
exception = strip: jdk.internal
writer = file
writer.format = {date} [{class}] {level}: {message}
writer.file = log.txt
In this way, when there is no error, I see proper logging. But purposefully I gave wrong mysql connection properties, and then I see whole bunch of error logs on console but on the log file I see only debug, info logs.
This is likely due to one of the following two causes:
1) The Maven Configuration is Incomplete
For using tinylog instead of Logback, which is the default logging back-end of Spring Boot, you have to exclude Spring Boot's logging dependencies and replace them with the corresponding tinylog artifacts:
(Copied from https://github.com/pmwmedia/tinylog-spring-boot-example/blob/v2/pom.xml)
2) Exception is not Output via a Logger
Have you checked that the exception is logged via a logger (e.g.
Logger.error(ex)
) and not printed viaex.printStackTrace()
directly to the console? tinylog (and any other logging framework) can only write log entries into files, if these log entries are issued via logging API.If none of both suggestions fix the issue, it would be helpful to know which logging API is being used to log the missing exception.