Implementation Issues with Log4j in Eclipse EMF RCP Using Java 17 and not OSG

24 Views Asked by At

I'm working with Eclipse EMF RCP using Java 17 and trying to implement a logging system using Log4j. Despite various attempts, I'm unable to get it to work, including the creation of a directory for saving log messages. I've set up a standard Log4j2.xml configuration in the src folder and created a static Log4j instance with a loggerManager in the class that should generate log messages, but nothing seems to function. Any suggestions would be greatly appreciated.

I tried to use this standard file log4j2.xml:

`<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
    <Appenders>
        <File name="LogFile" fileName="logs/app.log">
            <PatternLayout>
                <Pattern>%d{yyyy-MM-dd HH:mm:ss} [%t] %-5level %logger{36} - %msg%n</Pattern>
            </PatternLayout>
        </File>
    </Appenders>
    <Loggers>
        <Root level="debug">
            <AppenderRef ref="LogFile"/>
        </Root>
    </Loggers>
</Configuration>`

and tried to put this in the class. `import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger;

public class MyClass { private static final Logger logger = LogManager.getLogger(MyClass.class);`

I hope at least to get somme messages log in the logs/app.log and to create a view to read these messages

0

There are 0 best solutions below