diff options
Diffstat (limited to 'container-accesslogging/src/main/java/com/yahoo/container/logging/JSONAccessLog.java')
-rw-r--r-- | container-accesslogging/src/main/java/com/yahoo/container/logging/JSONAccessLog.java | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/container-accesslogging/src/main/java/com/yahoo/container/logging/JSONAccessLog.java b/container-accesslogging/src/main/java/com/yahoo/container/logging/JSONAccessLog.java new file mode 100644 index 00000000000..467618fdc2e --- /dev/null +++ b/container-accesslogging/src/main/java/com/yahoo/container/logging/JSONAccessLog.java @@ -0,0 +1,36 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.container.logging; + +import com.yahoo.container.core.AccessLogConfig; + +import java.util.logging.Level; + +/** + * Log a message in Vespa JSON access log format. + * + * @author frodelu + * @author tonytv + */ +public final class JSONAccessLog implements AccessLogInterface { + + private final AccessLogHandler logHandler; + + public JSONAccessLog(AccessLogConfig config) { + logHandler = new AccessLogHandler(config.fileHandler()); + } + + @Override + public void log(final AccessLogEntry logEntry) { + logHandler.access.log(Level.INFO, new JSONFormatter(logEntry).format() + '\n'); + } + + // TODO: This is never called. We should have a DI provider and call this method from its deconstruct. + public void shutdown() { + logHandler.shutdown(); + } + + void rotateNow() { + logHandler.rotateNow(); + } + +} |