[英]How to disable WARN messages and enable only INFO messages in logs through application.properties in Spring boot application?
I have tried using the below property value in my application.properties to enable only logger INFO messages. 我尝试在application.properties中使用以下属性值来仅启用记录器INFO消息。 But looks like it does not work as expected.
但是看起来它没有按预期工作。 I still see the WARNING messages appear along with INFO messages.
我仍然看到WARNING消息和INFO消息一起出现。 But I only want INFO messages to appear, am I doing something wrong here?
但是我只希望出现INFO消息,我在这里做错了吗?
logging.level.root=INFO logging.level.root = INFO
2018-12-21 09:46:25.312 INFO 12364 --- [nio-8081-exec-2] c.m.s.abc.util.FileUploadUtil : Sample message 1
2018-12-21 09:46:25.316 INFO 12364 --- [nio-8081-exec-2] c.m.service.abc.util.EnvelopeUtil : Sample message 2
2018-12-21 09:46:25.316 INFO 12364 --- [nio-8081-exec-2] c.m.service.abc.util.EnvelopeUtil : Sample message 3
2018-12-21 09:46:25.316 INFO 12364 --- [nio-8081-exec-2] c.m.service.abc.util.EnvelopeUtil : Sample message 4
2018-12-21 09:46:27.813 WARN 12364 --- [nio-8081-exec-2] o.a.pdfbox.pdmodel.font.PDType0Font : No Unicode mapping for CID+11 (11) in font ArialNarrow-Bold-Identity-H
2018-12-21 09:46:27.813 WARN 12364 --- [nio-8081-exec-2] o.a.pdfbox.pdmodel.font.PDType0Font : No Unicode mapping for CID+48 (48) in font ArialNarrow-Bold-Identity-H
2018-12-21 09:46:27.813 WARN 12364 --- [nio-8081-exec-2] o.a.pdfbox.pdmodel.font.PDType0Font : No Unicode mapping for CID+68 (68) in font ArialNarrow-Bold-Identity-H
2018-12-21 09:46:27.813 WARN 12364 --- [nio-8081-exec-2] o.a.pdfbox.pdmodel.font.PDType0Font : No Unicode mapping for CID+86 (86) in font ArialNarrow-Bold-Identity-H
2018-12-21 09:46:27.814 WARN 12364 --- [nio-8081-exec-2] o.a.pdfbox.pdmodel.font.PDType0Font : No Unicode mapping for CID+88 (88) in font ArialNarrow-Bold-Identity-H
2018-12-21 09:46:27.814 WARN 12364 --- [nio-8081-exec-2] o.a.pdfbox.pdmodel.font.PDType0Font : No Unicode mapping for CID+87 (87) in font ArialNarrow-Bold-Identity-H
You're not doing anything wrong, but none of the logging systems supported by Spring Boot (Logback, Log4j2, JUL) work as you expect. 您没有做错任何事情,但是Spring Boot支持的所有日志记录系统(Logback,Log4j2,JUL)都无法按预期工作。 When you set the level for a particular logger, it will log everything at that level and above.
当您为特定的记录器设置级别时,它将记录该级别及更高级别的所有内容。 As you have seen, that means that when
INFO
level logging is enabled, WARN
(and ERROR
) messages will also be logged. 如您所见,这意味着当启用
INFO
级别日志记录时,还将记录WARN
(和ERROR
)消息。
If you want to only log messages for a specific level, you'll have to use more complex configuration. 如果只想记录特定级别的消息,则必须使用更复杂的配置。 For example, Logback provides a
LevelFilter
that provides the behaviour you want. 例如,Logback提供了提供所需行为的
LevelFilter
。 To configure it, you'll have to use logback.xml
rather than relying solely on Spring Boot's application properties. 要配置它,您将不得不使用
logback.xml
而不是仅仅依靠Spring Boot的应用程序属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.