Spring Boot Actuator Logback Logger Conflict

๐Ÿ’ก Spring Boot Actuator Logback Logger Conflict โ€” Executive Summary

Technical architectural analysis, practical configuration manifests, and deployment instructions for Spring Boot Actuator Logback Logger Conflict.

Looking at this setting, changing the log level through Actuator is likely not possible in some packages.

I will analyze the cause and suggest a solution. ๐Ÿš€


๐Ÿ”Ž Problem Analysis
โœ… 1๏ธโƒฃ root log level fixed to WARN
xml
xml
๋ณต์‚ฌํŽธ์ง‘
<root level="warn">
  • root log level is set to WARN.
  • Even if you change the root log level in Actuator, there is a possibility that only WARN or higher will be output.
  • Because root is WARN, it may not be applied even if certain packages are set to DEBUG.

๐Ÿ”น How to check

  • Check current root log level with endpoint /actuator/loggers/root
txt
sh
๋ณต์‚ฌํŽธ์ง‘
curl -X GET http://localhost:8080/actuator/loggers/root
  • Example response
json
json
๋ณต์‚ฌํŽธ์ง‘
{
  "configuredLevel": "WARN",
  "effectiveLevel": "WARN"
}
  • If effectiveLevel is maintained even if configuredLevel is changed, root settings have been applied first.

โœ… 2๏ธโƒฃ Certain packages (e.g. iaas, org.springframework) force level in logback
xml
xml
๋ณต์‚ฌํŽธ์ง‘
<logger name="iaas" level="debug" additivity="false">
xml
xml
๋ณต์‚ฌํŽธ์ง‘
<logger name="org.springframework" level="debug" additivity="false">
  • If the log level of a specific package is hardcoded in logback.xml, it cannot be changed in Actuator.
  • Actuator changes settings dynamically, but override is not possible if level="debug" is specified in the logback.

๐Ÿ”น How to check

  • Check current settings with endpoint /actuator/loggers/iaas
txt
sh
๋ณต์‚ฌํŽธ์ง‘
curl -X GET http://localhost:8080/actuator/loggers/iaas
  • Example response
json
json
๋ณต์‚ฌํŽธ์ง‘
{
  "configuredLevel": "null",
  "effectiveLevel": "DEBUG"
}
  • If configuredLevel is null, it cannot be changed in the Actuator.
  • The actuator change is not applied because it is forcibly set to level="debug".

๐Ÿš€ Solution (Make log level changeable in Actuator)
โœ… 1๏ธโƒฃ root Lower log level and adjust specific packages to be able to be changed to Actuators

Currently, root is set to WARN, so there is a possibility that changes will not be reflected in Actuator.

xml
xml
๋ณต์‚ฌํŽธ์ง‘
<root level="DEBUG">

If you change it like this, there is a higher possibility that the settings changed in Actuator will be applied.


โœ… 2๏ธโƒฃ Remove the level property of a specific package and make it changeable in the Actuator

Currently, the log level of a specific package is hard-coded as shown below, so it cannot be changed in Actuator.

xml
xml
๋ณต์‚ฌํŽธ์ง‘
<logger name="iaas" level="debug" additivity="false">
xml
xml
๋ณต์‚ฌํŽธ์ง‘
<logger name="org.springframework" level="debug" additivity="false">

โžก If you change it like this, you can change it dynamically in the actuator.

xml
xml
๋ณต์‚ฌํŽธ์ง‘
<logger name="iaas" additivity="false">
    <appender-ref ref="consoleAppender"/>
    <appender-ref ref="dailyRollingFileAppender"/>
    <appender-ref ref="overwriteFileAppender"/>
</logger>

<logger name="org.springframework" additivity="false">
    <appender-ref ref="consoleAppender"/>
    <appender-ref ref="dailyRollingFileAppender"/>
    <appender-ref ref="overwriteFileAppender"/>
</logger>

๐Ÿš€ If you modify it like this, you can dynamically change the log level in the actuator.


โœ… 3๏ธโƒฃ Activate Actuator log change function (checkwrite: true)

In application.yml, you must check whether the loggers endpoint of the Actuator is write enabled.

yaml
yaml
๋ณต์‚ฌํŽธ์ง‘
management:
  endpoints:
    web:
      exposure:
        include: loggers
  endpoint:
    loggers:
      enabled: true
      write: true  # โœ… ๋กœ๊ทธ ๋ ˆ๋ฒจ ๋ณ€๊ฒฝ ๊ฐ€๋Šฅํ•˜๋„๋ก ์„ค์ •
  • If there is no write: true setting, the log level cannot be changed in the actuator.
  • Need to check whether the settings are applied in the operating environment.

๐Ÿš€ Final Summary (Things that need to be fixed)

โœ” Lower the log level of root to enable log changes

โœ” Remove the level="debug" setting of a specific package from logback-spring.xml and make it changeable in Actuator

โœ” Check the Actuator’s write: true setting in application.yml


If you modify it like this, you will be able to change the log in Actuator! ๐Ÿš€

If there is something that doesn’t work after testing, you can check it further. ๐Ÿ’ช

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *