問題文
A detailed message is assembled by joining several values, and in production the logger discards records at that level. How can the cost of assembling the text be avoided?
選択肢
- Ask the logger whether that level would be recorded before assembling, or hand over a supplier that assembles the text on demand
- Set the handler of the logger to a lower level, because the handler decides whether the caller assembles the text at all
- Keep the assembled message in a field of the class and log that field, because a field is evaluated once while the class is initialized
- Lower the level of the logger while the program is running, because the text is assembled by the handler instead of by the code that calls the logger