Please instead of downvoting have a look at my problem and help me out of this.
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class NewClass {
private static final Logger logger = LogManager.getLogger(NewClass.class);
public static void main(final String... args) {
// Set up a simple configuration that logs on the console.
logger.info("in info");
logger.trace("Entering application.");
Hello bar = new Hello();
if (!bar.doIt()) {
logger.error("Didn't do it.");
}
logger.trace("Exiting application.");
}
}
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class Hello {
static final Logger logger = LogManager.getLogger(Hello.class.getName());
public boolean doIt() {
logger.entry();
logger.error("Did it again!");
return logger.exit(false);
}
}
Configuration
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="error">
<AppenderRef ref="Console"/>
</Root>
<Root level="info">
<AppenderRef ref="Console"/>
</Root>
<Root level="trace">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>
As in here I am able to print everything on the console but I'm not sure how to append the records in three different files in a folder for error, info and trace. I'm not sure how to code for it. Thank you for the help.