Skip to content

Current log level not checked by LogAccessor supplier-enabled logging methods #25741

@rschuetz

Description

@rschuetz

Affects: Spring Framework version: 5.2.8

org.springframework.kafka.core.KafkaTemplate is using the org.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 additional SupplierMessage 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 of spring-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 in LogAccessor in these methods, to avoid creating objects / converting the objects to String unnecessarily?

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions