comparison src/goodjava/logger/examples/LogFile.java @ 1454:219f2b937f2b

remove log4j
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 08 Mar 2020 14:11:30 -0600
parents
children
comparison
equal deleted inserted replaced
1453:928be2a4d565 1454:219f2b937f2b
1 package goodjava.logger.examples;
2
3 import goodjava.logging.Logger;
4 import goodjava.logging.LoggerFactory;
5 import goodjava.logger.Layout;
6 import goodjava.logger.Layouts;
7 import goodjava.logger.DateLayout;
8 import goodjava.logger.ListLayout;
9 import goodjava.logger.Appender;
10 import goodjava.logger.WriterAppender;
11 import goodjava.logger.Level;
12 import goodjava.logger.SimpleConfigurer;
13 import goodjava.logger.GoodLoggerFactory;
14 import java.io.FileWriter;
15 import java.io.IOException;
16
17
18 public class LogFile {
19 private static final Logger logger = LoggerFactory.getLogger(LogFile.class);
20
21 public static void main(String[] args) throws Exception {
22 config();
23 logger.debug("test debug");
24 logger.info("test info");
25 logger.warn("test warn");
26 logger.error("test error");
27 }
28
29 static void config() throws IOException {
30 Layout layout = new ListLayout(new DateLayout("yyyy-MM-dd HH:mm:ss,SSS")," ",Layouts.LEVEL_PADDED," ",Layouts.LOGGER," - ",Layouts.MESSAGE,"\n",Layouts.THROWABLE);
31 Appender appender = new WriterAppender(layout,new FileWriter("test.log",true));
32 GoodLoggerFactory.setConfigurer( new SimpleConfigurer(Level.INFO,appender) );
33 }
34 }