1 16 17 package examples.lf5.UsingLogMonitorAdapter; 18 19 import org.apache.log4j.lf5.LogLevel; 20 import org.apache.log4j.lf5.util.LogMonitorAdapter; 21 22 32 33 35 public class CustomizedLogLevels { 36 public final static LogLevel LEVEL_ONE = new LogLevel("LEVEL 1", 1); 40 public final static LogLevel LEVEL_TWO = new LogLevel("LEVEL 2", 2); 41 public final static LogLevel LEVEL_THREE = new LogLevel("LEVEL 3", 3); 42 public final static LogLevel LEVEL_FOUR = new LogLevel("LEVEL 4", 4); 43 public final static LogLevel DEFAULT = new LogLevel("DEFAULT", 0); 44 45 49 private static LogMonitorAdapter _adapter; 53 54 static { 55 _adapter = LogMonitorAdapter.newInstance(new LogLevel[]{DEFAULT, LEVEL_ONE, 57 LEVEL_TWO, LEVEL_THREE, LEVEL_FOUR, LogLevel.FATAL}); 58 } 61 65 69 public static void main(String [] args) { 70 CustomizedLogLevels test = new CustomizedLogLevels(); 71 test.doMyBidding(); 72 } 73 74 public void doMyBidding() { 75 _adapter.setSevereLevel(LEVEL_ONE); 77 78 String levels = this.getClass().getName(); 79 80 _adapter.log(levels, "Using the customized LogLevels"); 82 83 _adapter.log(levels, LEVEL_FOUR, "This is a test"); 84 _adapter.log(levels, LEVEL_THREE, "Hmmm fobidden doughnut"); 85 _adapter.log(levels, LEVEL_ONE, "Danger Danger Will Robinson", 86 new RuntimeException ("DANGER"), "32"); 87 _adapter.log(levels, LEVEL_TWO, "Exit stage right->"); 88 _adapter.log(levels, LEVEL_FOUR, "What's up Doc?", 89 new NullPointerException ("Unfortunate exception")); 90 91 } 92 93 97 101 } 105 106 107 108 109 110 | Popular Tags |