Issue
In spring boot, it's possible to specify a different log level at the package or even file level.
logging.level.com.company.project.monitors=DEBUG
logging.level.com.company.project.controllers=INFO
logging.level.com.company.project.controllers.utils=WARN
Is there anything similar in Ktor where we can set different logging for individual areas of the app (without writing a bunch of code)?
Solution
What you describe isn't Spring Boot specific feature as such, but of the underlying logging library both Spring Boot and Ktor use by default.
In order to achieve the same behaviour in Ktor, add the following lines to your logback.xml
file:
<logger name="com.company.project.monitors" level="DEBUG" />
<logger name="com.company.project.controllers" level="INFO" />
<logger name="com.company.project.controllers.utils" level="WARN" />
The logback.xml
should be located in your src/main/resources
directory, if you're using Gradle as your build tool.
You can read more about Logback support in Ktor here: https://ktor.io/docs/logging.html#add_dependencies
Answered By - Alexey Soshin
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.