Mercurial Hosting > luan
comparison src/org/eclipse/jetty/server/NCSARequestLog.java @ 854:359012f4e797
minor
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Tue, 20 Sep 2016 01:05:37 -0600 |
| parents | 3242aff51053 |
| children | fa6158f29c45 |
comparison
equal
deleted
inserted
replaced
| 853:3242aff51053 | 854:359012f4e797 |
|---|---|
| 50 /** | 50 /** |
| 51 */ | 51 */ |
| 52 public class NCSARequestLog extends AbstractLifeCycle implements RequestLog | 52 public class NCSARequestLog extends AbstractLifeCycle implements RequestLog |
| 53 { | 53 { |
| 54 private static final Logger LOG = LoggerFactory.getLogger(NCSARequestLog.class); | 54 private static final Logger LOG = LoggerFactory.getLogger(NCSARequestLog.class); |
| 55 private static final String __LINE_SEPARATOR= | |
| 56 System.getProperty("line.separator","\n"); | |
| 57 | 55 |
| 58 private String _filename; | 56 private String _filename; |
| 59 private boolean _extended; | 57 private boolean _extended; |
| 60 public long sizeLimit = 1048576L; | 58 public long retainTime = 1000L*60*60*24*31; // 31 days |
| 61 private boolean _closeOut; | 59 private boolean _closeOut; |
| 62 private boolean _preferProxiedForAddress; | 60 private boolean _preferProxiedForAddress; |
| 63 private String _logDateFormat = "dd/MMM/yyyy:HH:mm:ss Z"; | 61 private String _logDateFormat = "dd/MMM/yyyy:HH:mm:ss Z"; |
| 64 private Locale _logLocale = Locale.getDefault(); | 62 private Locale _logLocale = Locale.getDefault(); |
| 65 private String _logTimeZone = "GMT"; | 63 private String _logTimeZone = "GMT"; |
| 453 buf.append(' '); | 451 buf.append(' '); |
| 454 buf.append(now - request.getTimeStamp()); | 452 buf.append(now - request.getTimeStamp()); |
| 455 } | 453 } |
| 456 } | 454 } |
| 457 | 455 |
| 458 buf.append(__LINE_SEPARATOR); | 456 buf.append('\n'); |
| 459 | 457 |
| 460 String log = buf.toString(); | 458 String log = buf.toString(); |
| 461 write(log); | 459 write(log); |
| 462 } | 460 } |
| 463 catch (IOException e) | 461 catch (IOException e) |
| 528 _logDateCache.setTimeZoneID(_logTimeZone); | 526 _logDateCache.setTimeZoneID(_logTimeZone); |
| 529 } | 527 } |
| 530 | 528 |
| 531 if (_filename != null) { | 529 if (_filename != null) { |
| 532 File file = new File(_filename); | 530 File file = new File(_filename); |
| 533 if( file.exists() && file.length() > sizeLimit ) { | 531 if( file.exists() ) { |
| 534 File old = new File(_filename+".old"); | 532 File old = new File(_filename+".old"); |
| 535 old.delete(); | 533 if( old.exists() && file.lastModified() - old.lastModified() > retainTime ) |
| 536 file.renameTo(old); | 534 old.delete(); |
| 535 if( !old.exists() ) | |
| 536 file.renameTo(old); | |
| 537 } | 537 } |
| 538 _out = new FileOutputStream(file,true); | 538 _out = new FileOutputStream(file,true); |
| 539 _closeOut = true; | 539 _closeOut = true; |
| 540 LOG.info("Opened " + _filename); | 540 LOG.info("Opened " + _filename); |
| 541 } | 541 } |
