I have a log4j2.xml which works correctly, until I export the project. The basePath in this case configured manually. So the log file location is correct even after export. After the exporting, just the console work. Export works with the required JAR files: slf4j-api-2.0.12.jar, log4j-core-2.22.1.jar, log4j-api-2.22.1.jar. etc…
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Properties>
<Property name="basePath">C:Tempprinterlogs</Property>
</Properties>
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level - %msg%n" />
</Console>
<File name="emailFile" fileName="${basePath}emails.log">
<PatternLayout>
<Pattern>%d %p %c{1.}: %m%n</Pattern>
</PatternLayout>
</File>
<File name="errorFile" fileName="${basePath}errors.log">
<PatternLayout>
<Pattern>%d %p %c{1.}: %m%n</Pattern>
</PatternLayout>
</File>
<File name="infoFile" fileName="${basePath}information.log">
<PatternLayout>
<Pattern>%d %p %c{1.}: %m%n</Pattern>
</PatternLayout>
</File>
</Appenders>
<Loggers>
<Logger name="generalLog" level="info" additivity="false">
<AppenderRef ref="Console"/>
<AppenderRef ref="infoFile"/>
<AppenderRef ref="errorFile" level="error"/>
</Logger>
<Logger name="emailLog" level="info" additivity="false">
<AppenderRef ref="Console"/>
<AppenderRef ref="emailFile"/>
</Logger>
<Root level="info">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>
I checked the paths, jar files, but everything was fine.
I changed everywhere in the xml: <File name="emailFile" fileName="${basePath}emails.log">
to <File name="emailFile" fileName="C:Tempprinterlogsemails.log">
I saw that someone had the same question, but they had a problem with the path, but this problem does not exist in this case.