Skip to content

Commit

Permalink
Issue GoogleCloudPlatform#231 - Cleaning up RequestLog logging behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
joakime committed Jun 29, 2016
1 parent db8cc2e commit 768d936
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,14 @@ private static void systemConfig() throws IOException {
// makes sense to use the ServiceLoader to obtain references to specific System loggers
// that need to be initialized during this step in the logging initialization.

int count = 0;
ServiceLoader<SystemLogger> serviceLoader = ServiceLoader.load(SystemLogger.class);
for (SystemLogger systemLogger : serviceLoader) {
debug("Executing SystemLogger: %s", systemLogger.getClass().getName());
systemLogger.configure();
count++;
}
debug("Ran $d SystemLogger(s)", count);
}

private static void debug(String format, Object... args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class VmRuntimeFileLogHandler extends FileHandler implements SystemLogger
"com.google.apphosting.vmruntime.VmRuntimeFileLogHandler.pattern";
// Log files to /var/log/app_engine/app.[0-2].log.json
private static final String DEFAULT_LOG_DIRECTORY = "/var/log/app_engine";
private static final String DEFAULT_LOG_PATTERN = "app.%g.log.json";
private static final String DEFAULT_LOG_PATTERN = "app.%u.%g.log.json";
private static final String APP_ENGINE_LOG_CONFIG_PATTERN_ENV = "APP_ENGINE_LOG_CONFIG_PATTERN";
private static final int LOG_PER_FILE_SIZE = 100 * 1024 * 1024;
private static final int LOG_MAX_FILES = 3;
Expand Down
5 changes: 1 addition & 4 deletions jetty9-base/src/main/jetty-base/etc/gae.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,7 @@
<Arg>
<New id="RequestLog" class="org.eclipse.jetty.server.handler.RequestLogHandler">
<Set name="requestLog">
<New id="RequestLogImpl" class="org.eclipse.jetty.server.NCSARequestLog">
<Arg><Property name="com.google.apphosting.logs" default="/var/log/app_engine" />/request.yyyy_mm_dd.log</Arg>
<Set name="retainDays">2</Set>
<Set name="append">true</Set>
<New id="RequestLogImpl" class="org.eclipse.jetty.server.Slf4jRequestLog">
<Set name="extended">true</Set>
<Set name="LogTimeZone">GMT</Set>
<Set name="logLatency">true</Set>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,22 @@

import java.io.IOException;
import java.util.logging.FileHandler;
import java.util.logging.Formatter;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;

public class RequestLoggerHandler extends FileHandler implements SystemLogger {
public static class RequestLogFormatter extends Formatter {
@Override
public String format(LogRecord record) {
// We don't expand the message, or use the ResourceBundle stuff for this formatter.
return record.getMessage();
}
}


public static final String LOG_DIRECTORY_PROPERTY = "com.google.apphosting.logs";
private static final String DEFAULT_LOG_DIRECTORY = "/var/log/app_engine";
private static final String DEFAULT_LOG_PATTERN = "access.%g.log";
Expand All @@ -19,6 +30,7 @@ public class RequestLoggerHandler extends FileHandler implements SystemLogger {

public RequestLoggerHandler() throws IOException, SecurityException {
super(getFilePattern(), LOG_PER_FILE_SIZE, LOG_MAX_FILES, LOG_APPEND);
setFormatter(new RequestLogFormatter());
}

private static String getFilePattern() {
Expand Down

0 comments on commit 768d936

Please sign in to comment.