Class SamplingLogger


  • public class SamplingLogger
    extends DelegatingLogger
    A sampling logger that can be enabled and disabled dynamically by setting its level to Level.FINEST.
    Author:
    [email protected]
    • Constructor Detail

      • SamplingLogger

        public SamplingLogger​(com.wavefront.data.ReportableEntityType entityType,
                              Logger delegate,
                              double samplingRate,
                              boolean alwaysActive,
                              @Nullable
                              Consumer<String> statusChangeConsumer)
        Parameters:
        entityType - entity type (used in info messages only).
        delegate - delegate logger name.
        samplingRate - sampling rate for logging [0..1].
        alwaysActive - whether this logger is always active regardless of currently set log level.
    • Method Detail

      • log

        public void log​(Level level,
                        String message)
        Checks the logger state and writes the message in the log if appropriate. We log valid points only if the system property wavefront.proxy.logpoints is true (for legacy reasons) or the delegate logger's log level is set to "ALL" (i.e. if Level.FINEST is considered loggable). This is done to prevent introducing additional overhead into the critical path, as well as prevent accidentally logging points into the main log. Additionally, honor sample rate limit, if set.
        Specified by:
        log in class DelegatingLogger
        Parameters:
        level - log level.
        message - string to write to log.