Tuesday, June 21, 2022

Quickly run log4j2 without properties files

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

A game jam

I recently (the last weekend) developed a game for a "game jam" hosted on ItchIO. For those new to this term, the "game jam...