Skip to content

Instantly share code, notes, and snippets.

@lol97
Created March 31, 2024 12:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lol97/7df1f4b81b576bf24ae63634f0f6190e to your computer and use it in GitHub Desktop.
Save lol97/7df1f4b81b576bf24ae63634f0f6190e to your computer and use it in GitHub Desktop.
custom level log
package com.sufyan97.learn_log4j;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class LevelLogCustom {
private static Logger log = LogManager.getLogger(LevelLogCustom.class);
//custom BAHAYA_TA
final static Level BAHAYA_TA = Level.forName("BAHAYA_TA", 250);
public static void main(String[] args) {
log.trace("Hai ini trace");
log.debug("Hai ini info");
log.info("Hai ini info");
log.warn("Hai ini warning message");
log.log(BAHAYA_TA, "waduhhh");
log.log(Level.getLevel("BAHAYA_TA"), "lurrrr");
log.error("Errrrrrrr");
//custom SEBAIKNYA_JANGAN_BERCANDA
log.log(Level.forName("SEBAIKNYA_JANGAN_BERCANDA", 150), "tulung lur");
log.fatal("fatalll");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment