Class LoggingInterceptor


  • public class LoggingInterceptor
    extends Handler
    A logging interceptor that publishes log records to Google Cloud Logging. This class extends Handler to integrate with the Java logging framework.
    • Constructor Detail

      • LoggingInterceptor

        public LoggingInterceptor​(com.google.auth.oauth2.GoogleCredentials credentials,
                                  String logNameSuffix)
        Constructs a new LoggingInterceptor.
        Parameters:
        credentials - the Google Cloud credentials used to authenticate with the Logging service
        logNameSuffix - the suffix to append to the log name
    • Method Detail

      • createLoggingService

        protected com.google.cloud.logging.Logging createLoggingService​(com.google.auth.oauth2.GoogleCredentials credentials)
        Creates a Google Cloud Logging service instance.
        Parameters:
        credentials - the Google Cloud credentials used to authenticate with the Logging service
        Returns:
        a Logging instance
      • publish

        public void publish​(LogRecord record)
        Publishes a log record to Google Cloud Logging.
        Specified by:
        publish in class Handler
        Parameters:
        record - the log record to publish
      • flush

        public void flush()
        Flushes any buffered log entries to Google Cloud Logging.
        Specified by:
        flush in class Handler