Classes:
- Logger
- Categories
- Priorities
- Fatal
- Error
- Warn
- Info
- Debug
- Appenders
- Layouts
xml configured file has higher priority than properties file (log4j.xml is with highest priority than log4j.properties). Sample log4j.xml
The test class:
import org.apache.log4j.Logger;
public class Main {
/**
* Logger for this class
*/
private static final Logger logger = Logger.getLogger(Main.class);
public static void main(String[] args) {
if (logger.isDebugEnabled()) {
logger.debug("main(String[]) - start");
}
if (logger.isDebugEnabled()) {
logger.debug("main(String[]) - TADA Info - args=" + args);
}
logger.error("main(String[]) - Tada Severe", null);
if (logger.isEnabledFor(org.apache.log4j.Level.FATAL)) {
logger.fatal("main(String[]) - rsere", null);
}
logger.warn("main(String[]) - asfas", null);
if (logger.isEnabledFor(org.apache.log4j.Level.WARN)) {
logger.warn("main(String[]) - asfasf", null);
}
if (logger.isInfoEnabled()) {
logger.info("main(String[]) - adfasdfsdf");
}
if (logger.isDebugEnabled()) {
logger.debug("main(String[]) - end");
}
}
}