Skip to main content
10-Marble
November 7, 2023
Solved

Log4j 2.0 updated APIs

  • November 7, 2023
  • 2 replies
  • 1648 views

Hello,

 

I am currently migrating the codebase from Windchill 11.1 to 12.0 and facing issues in the new log4j 2.0 package, namely in the following APIs-

Layout layout = new PatternLayout("%d [%t] %-5p %c - %m%n");
FileAppender appender = new FileAppender(layout, WTProperties
.getServerProperties().getProperty("wt.logs.dir")
+ File.separator + "SetStateOfAffectedObjects.log");

logger.addAppender(appender);

 

Anybody has any suggestions for the same?

 

Thank you,

Ramsha 

 

 

Best answer by HelesicPetr

Hi @RK_10805837 

So what is your problem?

If you import correct packages, there can not be any issue.

 

do not forget to import all sub packages correctly... 

PetrH

2 replies

avillanueva
23-Emerald I
23-Emerald I
November 7, 2023
HelesicPetr
22-Sapphire II
22-Sapphire II
November 8, 2023

Hi @RK_10805837 

If you migrating your code you need to update all apache logger import usage.

The logger is upgraded to new version so you need to change the apache package in any class import.

 

from

org.apache.log4j.Logger

to

org.apache.logging.log4j.Logger

 

the change apply for all apache log4j classes so

org.apache.logging.log4j.*

 

there is also variable change in the wt.properties file(but this is OOTB changed)

-Dlog4j2.configurationFile\=$(wt.manager.log4j.config)

 

PetrH

10-Marble
November 9, 2023

Hi @HelesicPetr ,

yes I have included those packages. I

avillanueva
23-Emerald I
23-Emerald I
November 9, 2023

I think your message was cut off.