public class AsyncLoggingHandler extends LoggingHandler
Logger to Stackdriver Logging.
Java logging levels (see Level) are mapped to the following Google
Stackdriver Logging severities:
| Java Level | Stackdriver Logging Severity |
|---|---|
| SEVERE | ERROR |
| WARNING | WARNING |
| INFO | INFO |
| CONFIG | INFO |
| FINE | DEBUG |
| FINER | DEBUG |
| FINEST | DEBUG |
Original Java logging levels are added as labels (with levelName and
levelValue keys, respectively) to the corresponding Stackdriver Logging LogEntry.
You can read entry labels using LogEntry.labels(). To use logging levels that correspond
to Stackdriver Logging severities you can use LoggingLevel.
Configuration: By default each AsyncLoggingHandler is initialized using the
following LogManager configuration properties (that you can set in the
logging.properties file. If properties are not defined (or have invalid values) then the
specified default values are used.
com.google.cloud.logging.AsyncLoggingHandler.log the log name (defaults to
java.log).
com.google.cloud.logging.AsyncLoggingHandler.level specifies the default level for
the handler (defaults to Level.INFO).
com.google.cloud.logging.AsyncLoggingHandler.filter specifies the name of a
Filter class to use (defaults to no filter).
com.google.cloud.logging.AsyncLoggingHandler.formatter specifies the name of a
Formatter class to use (defaults to SimpleFormatter).
com.google.cloud.logging.AsyncLoggingHandler.flushSize specifies the maximum size of
the log buffer. Once reached, logs are transmitted to the Stackdriver Logging service
(defaults to 1).
com.google.cloud.logging.AsyncLoggingHandler.flushLevel specifies the flush log
level. When a log with this level is published, logs are transmitted to the Stackdriver
Logging service (defaults to LoggingLevel.ERROR).
To add a LoggingHandler to an existing Logger and be sure to avoid infinite
recursion when logging, use the LoggingHandler.addHandler(Logger, LoggingHandler) method. Alternatively
you can add the handler via logging.properties. For example using the following line:
com.example.mypackage.handlers=com.google.cloud.logging.AsyncLoggingHandler
| Constructor and Description |
|---|
AsyncLoggingHandler() |
AsyncLoggingHandler(String logName) |
AsyncLoggingHandler(String logName,
LoggingOptions options) |
AsyncLoggingHandler(String logName,
LoggingOptions options,
MonitoredResource resource) |
addHandler, close, flush, publish, setFlushLevel, setFlushSizegetEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggable, reportError, setEncoding, setErrorManager, setFilter, setFormatter, setLevelpublic AsyncLoggingHandler()
public AsyncLoggingHandler(String logName)
public AsyncLoggingHandler(String logName, LoggingOptions options)
public AsyncLoggingHandler(String logName, LoggingOptions options, MonitoredResource resource)
Copyright © 2016 Google. All rights reserved.