Open ecourreges-orange opened 1 month ago
@ecourreges-orange Thank you for this report. Which version of logback are you using?
@ecourreges-orange Thank you for this report. Which version of logback are you using?
logback-classic 1.5.5
With logstash-logback-encoder 6.6
Hello, I will show you two configurations, one that works, one that doesn't, and maybe you understand what is wrong.
If it's not a bug, this requires at least clear documentation warnings on conditionals.
This first logback.xml works for all combinations of API_LOGS_FS_ENABLED, API_LOGS_TXT_ENABLED: specifically If these two variables are false, I have my last UdpJsonAppender working on the root logger, and the JsonAppender and TextAppender create empty files which are never filled, I guess this is expected.
Whereas in this one, the UdpJsonAppender works only if API_LOGS_FS_ENABLED, API_LOGS_TXT_ENABLED are both true, which is totally unexpected, and makes me think that the root logger evaluates the last if condition only if the appender-ref of JsonAppender and TextAppender are valid, which in this case they are not since their block is also enclosed in a conditional which is false, so the appenders are never declared, but the ifs inside the root are also false so they should be ignored and the one for UdpJsonAppender should still be OK.
This one would have the clear advantage of not creating the resources or the file for the unused appenders, but in practice, it doesn't work.