'How to implement Pattern Layout in log4j2 2.17.1 migrated from log4j 1.2.17 version?
Migrated from log4j 1.2.17 to log4j2 2.17.1 and getting issue in Pattern Layout class.
PatternLayout pl = PatternLayout();
pl.setConversionPattern("%m :%d%n");
// setFile(new File(theQFileName));
FileAppender appender;
try {
appender = new FileAppender(pl, theQFileName, false);
lLogger.addAppender(appender);
}
Above snippet was used in log4j 1.2.17 version and after migration getting compilation error for Pattern Layout and File Appender class.
[ERROR] PatternLayout pl = new PatternLayout();
[ERROR] ^^^^^^^^^^^^^^^^^^^
[ERROR] The constructor PatternLayout() is undefined
[ERROR] pl.setConversionPattern("%m :%d%n");
[ERROR] ^^^^^^^^^^^^^^^^^^^^
[ERROR] The method setConversionPattern(String) is undefined for the type PatternLayout
[ERROR] appender = new FileAppender(pl, theQFileName, false);
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] The constructor FileAppender(PatternLayout, String, boolean) is undefined
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
