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();
}
Aggregations