diff src/goodjava/logger/examples/Console.java @ 1454:219f2b937f2b

remove log4j
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 08 Mar 2020 14:11:30 -0600
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/goodjava/logger/examples/Console.java	Sun Mar 08 14:11:30 2020 -0600
@@ -0,0 +1,32 @@
+package goodjava.logger.examples;
+
+import goodjava.logging.Logger;
+import goodjava.logging.LoggerFactory;
+import goodjava.logger.Layout;
+import goodjava.logger.Layouts;
+import goodjava.logger.DateLayout;
+import goodjava.logger.ListLayout;
+import goodjava.logger.Appender;
+import goodjava.logger.ConsoleAppender;
+import goodjava.logger.Level;
+import goodjava.logger.SimpleConfigurer;
+import goodjava.logger.GoodLoggerFactory;
+
+
+public class Console {
+	private static final Logger logger = LoggerFactory.getLogger(Console.class);
+
+	public static void main(String[] args) {
+		config();
+		logger.debug("test debug");
+		logger.info("test info");
+		logger.warn("test warn");
+		logger.error("test error");
+	}
+
+	static void config() {
+		Layout layout = new ListLayout(new DateLayout("yyyy-MM-dd HH:mm:ss,SSS")," ",Layouts.LEVEL_PADDED," ",Layouts.LOGGER," - ",Layouts.MESSAGE,"\n",Layouts.THROWABLE);
+		Appender appender = new ConsoleAppender(layout,System.err);
+		GoodLoggerFactory.setConfigurer( new SimpleConfigurer(Level.INFO,appender) );
+	}
+}