Sometimes I just want to use log4j without a properties file and log everything to console. It seems that especially for this reason there exists the DefaultConfiguration class. This applies to log4j2.
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.config.Configurator;
import org.apache.logging.log4j.core.config.DefaultConfiguration;
public static void main(String... aArgs) {Configurator.initialize(new DefaultConfiguration());Configurator.setRootLevel(Level.DEBUG);
No comments:
Post a Comment