Closed kojinoguchi closed 4 months ago
@kojinoguchi, SimpleLayout
is by design a no-op. When a Log4j 1 configuration is read, SimpleLayout
component will be replaced with a PatternLayout
– see SimpleLayoutBuilder
responsible for this transformation. But since you access the element programmatically, which is discouraged!1, you get the no-op component. In short, your Log4j 1 configurations using SimpleLayout
will work.
1 Log4j Core treats the configuration file as the public API. Even though we do our best to keep the binary backward compatibility for publicly visible classes, fields, etc. in the code, we don't give the same guarantee that we give for the configuration file syntax.
When a Log4j 1 configuration is read, SimpleLayout component will be replaced with a PatternLayout
Aaah, I see. In that case, I would have preferred if this empty SimpleLayout didn't exist or failed out with exception instead of silently swallowing the logs (no-op). Thanks anyways for the infoi!
Description
When using SimpleLayout provided in log4j-1.2-api, it doesn't log anything. Is this by design? In log4j1, it used to log with “%level - %m%n” pattern ?
Reproduction
From one of the unit-test we have. This produces empty logs. Works when replacing SimpleLayout with PatternLayout.