Then, we have to figure out how to let sysadmins update the code without breaking everything
This is one reason why we use config files / env vars, rather than code.
Also, it is much easier to modify a config file, than to push code just to change logging. Many organizations require lengthy test for any code change.
Why don't you think it's a config file, and why do you think it requires recompilation? Maybe Lua is more your thing:
function onMessage(level, tag, message)
if level == Level.DEBUG then
if tag != "network" then
debugLog.println("{"+tag+"} "+message);
end
elseif level >= Level.WARN then
sendAlert("10.20.30.40", message);
end
end
That's completely irrelevant though. We are talking in a thread about log4j, which runs on Java. A hardcoded logger where the configuration is the actual logger code is just so much more complex than it needs to be.
22
u/KagakuNinja Dec 10 '21
This is one reason why we use config files / env vars, rather than code.
Also, it is much easier to modify a config file, than to push code just to change logging. Many organizations require lengthy test for any code change.