Search in sources :

Example 6 with MonitoredResource

use of com.google.cloud.MonitoredResource in project google-cloud-java by GoogleCloudPlatform.

the class LoggingAppender method start.

/**
   * Initialize and configure the cloud logging service.
   */
@Override
public synchronized void start() {
    if (isStarted()) {
        return;
    }
    MonitoredResource resource = getMonitoredResource(getProjectId());
    defaultWriteOptions = new WriteOption[] { WriteOption.logName(getLogName()), WriteOption.resource(resource) };
    getLogging().setFlushSeverity(severityFor(getFlushLevel()));
    loggingEnhancers = new ArrayList<>();
    List<LoggingEnhancer> resourceEnhancers = MonitoredResourceUtil.getResourceEnhancers();
    loggingEnhancers.addAll(resourceEnhancers);
    loggingEnhancers.addAll(getLoggingEnhancers());
    super.start();
}
Also used : LoggingEnhancer(com.google.cloud.logging.LoggingEnhancer) MonitoredResource(com.google.cloud.MonitoredResource)

Aggregations

MonitoredResource (com.google.cloud.MonitoredResource)6 Test (org.junit.Test)3 Handler (java.util.logging.Handler)2 Builder (com.google.cloud.logging.LogEntry.Builder)1 LoggingEnhancer (com.google.cloud.logging.LoggingEnhancer)1 StringPayload (com.google.cloud.logging.Payload.StringPayload)1 WriteLogEntriesRequest (com.google.logging.v2.WriteLogEntriesRequest)1 Logger (java.util.logging.Logger)1