Created
March 31, 2024 12:38
-
-
Save lol97/7df1f4b81b576bf24ae63634f0f6190e to your computer and use it in GitHub Desktop.
custom level log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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