Mercurial Hosting > luan
comparison src/goodjava/webserver/handlers/LogHandler.java @ 1598:c78d6a4e2d9a
web logging
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 04 Apr 2021 15:09:51 -0600 |
parents | 329197048ff0 |
children | 8a717f0b7f45 |
comparison
equal
deleted
inserted
replaced
1597:cd2a0c41b23f | 1598:c78d6a4e2d9a |
---|---|
19 import goodjava.webserver.Request; | 19 import goodjava.webserver.Request; |
20 import goodjava.webserver.Response; | 20 import goodjava.webserver.Response; |
21 | 21 |
22 | 22 |
23 public final class LogHandler implements Handler { | 23 public final class LogHandler implements Handler { |
24 private static final Layout layout = new ListLayout(new DateLayout("yyyy-MM-dd:HH:mm:ss")," ",Layouts.MESSAGE,"\n"); | |
24 | 25 |
25 public static Logger consoleLogger() { | 26 public static Logger consoleLogger() { |
26 Layout layout = new ListLayout(new DateLayout("yyyy-MM-dd:HH:mm:ss")," ",Layouts.MESSAGE,"\n"); | |
27 Appender appender = new ConsoleAppender(layout,System.err); | 27 Appender appender = new ConsoleAppender(layout,System.err); |
28 GoodLogger logger = new GoodLogger("HTTP"); | 28 GoodLogger logger = new GoodLogger("HTTP"); |
29 logger.appender = appender; | 29 logger.appender = appender; |
30 logger.level = Level.INFO; | 30 logger.level = Level.INFO; |
31 return logger; | 31 return logger; |
37 try { | 37 try { |
38 IoUtils.mkdirs(dir); | 38 IoUtils.mkdirs(dir); |
39 } catch(IOException e) { | 39 } catch(IOException e) { |
40 throw new RuntimeException(e); | 40 throw new RuntimeException(e); |
41 } | 41 } |
42 Layout layout = new ListLayout(new DateLayout("yyyy-MM-dd:HH:mm:ss")," ",Layouts.MESSAGE,"\n"); | 42 DateFormat fmt = new SimpleDateFormat( "'" + dir + "/'yyyy_MM_dd'.log'" ); |
43 DateFormat fmt = new SimpleDateFormat( "'" + dir + "/'yyyy_MM_dd_HH_mm'.log'" ); | |
44 Appender appender = new DailyRollingFileAppender(layout,fmt); | 43 Appender appender = new DailyRollingFileAppender(layout,fmt); |
45 GoodLogger logger = new GoodLogger("HTTP"); | 44 GoodLogger logger = new GoodLogger("HTTP"); |
46 logger.appender = appender; | 45 logger.appender = appender; |
47 logger.level = Level.INFO; | 46 logger.level = Level.INFO; |
48 return logger; | 47 return logger; |