[LOGBack-dev] svn commit: r309 - logback/classic/trunk/src/main/java/ch/qos/logback

noreply.seb at qos.ch noreply.seb at qos.ch
Tue Jul 25 18:23:40 CEST 2006


Author: seb
Date: Tue Jul 25 18:23:39 2006
New Revision: 309

Added:
   logback/classic/trunk/src/main/java/ch/qos/logback/BasicConfigurator.java
Log:
initial commit

Added: logback/classic/trunk/src/main/java/ch/qos/logback/BasicConfigurator.java
==============================================================================
--- (empty file)
+++ logback/classic/trunk/src/main/java/ch/qos/logback/BasicConfigurator.java	Tue Jul 25 18:23:39 2006
@@ -0,0 +1,41 @@
+package ch.qos.logback;
+
+import org.slf4j.LoggerFactory;
+
+import ch.qos.logback.classic.Logger;
+import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.classic.PatternLayout;
+import ch.qos.logback.core.ConsoleAppender;
+
+public class BasicConfigurator {
+
+	public static void configure(LoggerContext lc) {
+		ConsoleAppender ca = new ConsoleAppender();
+		ca.setContext(lc);
+		ca.setName("console");
+		PatternLayout pl = new PatternLayout();
+		pl.setPattern("%m%n");
+		pl.start();
+
+		ca.setLayout(pl);
+		ca.start();
+		Logger rootLogger = lc.getRootLogger();
+		rootLogger.addAppender(ca);
+	}
+	
+	public static void configureDefaultContext() {
+		Logger logger = (Logger) LoggerFactory.getLogger(BasicConfigurator.class);
+		LoggerContext lc = logger.getLoggerContext();
+		ConsoleAppender ca = new ConsoleAppender();
+		ca.setContext(lc);
+		ca.setName("console");
+		PatternLayout pl = new PatternLayout();
+		pl.setPattern("%m%n");
+		pl.start();
+
+		ca.setLayout(pl);
+		ca.start();
+		Logger rootLogger = lc.getRootLogger();
+		rootLogger.addAppender(ca);
+	}
+}



More information about the logback-dev mailing list