Current log level not checked by LogAccessor supplier-enabled logging methods #25741
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
type: enhancement
A general enhancement
Milestone
Affects: Spring Framework version: 5.2.8
org.springframework.kafka.core.KafkaTemplate
is using theorg.springframework.core.log.LogAccessor
Supplier
-enabled logging methods (trace etc.). Unfortunately,LogAccessor
does not check the currently enabled log level, so it always creates an additionalSupplierMessage
object even of the data never gets logged. In addition, in case the standard JCL -> SLF4J bridge (jcl-over-slf4j.jar
) of the SLF4J project is being used instead ofspring-jcl
, the SLF4JLog class of this bridge unfortunately also converts the object to a string unconditionally, probably as it assumes the log level has been checked before, which slows down processing dramatically.Assuming that the
LogAccessor
Supplier
-enabled logging methods are intended to be called without log level check before, wouldn't it be better to at least check the log level inLogAccessor
in these methods, to avoid creating objects / converting the objects to String unnecessarily?The text was updated successfully, but these errors were encountered: