Package 

Class Logger


  • 
    public final class Logger
    
                        

    A class enabling Datadog logging features.

    It allows you to create a specific context (automatic information, custom attributes, tags) that will be embedded in all logs sent through this logger.

    You can have multiple loggers configured in your application, each with their own settings.

    • Method Detail

      • v

        @JvmOverloads() final Unit v(String message, Throwable throwable, Map<String, Object> attributes)

        Sends a VERBOSE log message.

        Parameters:
        message - the message to be logged
        throwable - a (nullable) throwable to be logged with the message
        attributes - a map of attributes to include only for this message.
      • v

        @JvmOverloads() final Unit v(String message, Throwable throwable)

        Sends a VERBOSE log message.

        Parameters:
        message - the message to be logged
        throwable - a (nullable) throwable to be logged with the message
      • v

        @JvmOverloads() final Unit v(String message)

        Sends a VERBOSE log message.

        Parameters:
        message - the message to be logged
      • d

        @JvmOverloads() final Unit d(String message, Throwable throwable, Map<String, Object> attributes)

        Sends a Debug log message.

        Parameters:
        message - the message to be logged
        throwable - a (nullable) throwable to be logged with the message
        attributes - a map of attributes to include only for this message.
      • d

        @JvmOverloads() final Unit d(String message, Throwable throwable)

        Sends a Debug log message.

        Parameters:
        message - the message to be logged
        throwable - a (nullable) throwable to be logged with the message
      • d

        @JvmOverloads() final Unit d(String message)

        Sends a Debug log message.

        Parameters:
        message - the message to be logged
      • i

        @JvmOverloads() final Unit i(String message, Throwable throwable, Map<String, Object> attributes)

        Sends an Info log message.

        Parameters:
        message - the message to be logged
        throwable - a (nullable) throwable to be logged with the message
        attributes - a map of attributes to include only for this message.
      • i

        @JvmOverloads() final Unit i(String message, Throwable throwable)

        Sends an Info log message.

        Parameters:
        message - the message to be logged
        throwable - a (nullable) throwable to be logged with the message
      • i

        @JvmOverloads() final Unit i(String message)

        Sends an Info log message.

        Parameters:
        message - the message to be logged
      • w

        @JvmOverloads() final Unit w(String message, Throwable throwable, Map<String, Object> attributes)

        Sends a Warning log message.

        Parameters:
        message - the message to be logged
        throwable - a (nullable) throwable to be logged with the message
        attributes - a map of attributes to include only for this message.
      • w

        @JvmOverloads() final Unit w(String message, Throwable throwable)

        Sends a Warning log message.

        Parameters:
        message - the message to be logged
        throwable - a (nullable) throwable to be logged with the message
      • w

        @JvmOverloads() final Unit w(String message)

        Sends a Warning log message.

        Parameters:
        message - the message to be logged
      • e

        @JvmOverloads() final Unit e(String message, Throwable throwable, Map<String, Object> attributes)

        Sends an Error log message.

        Parameters:
        message - the message to be logged
        throwable - a (nullable) throwable to be logged with the message
        attributes - a map of attributes to include only for this message.
      • e

        @JvmOverloads() final Unit e(String message, Throwable throwable)

        Sends an Error log message.

        Parameters:
        message - the message to be logged
        throwable - a (nullable) throwable to be logged with the message
      • e

        @JvmOverloads() final Unit e(String message)

        Sends an Error log message.

        Parameters:
        message - the message to be logged
      • wtf

        @JvmOverloads() final Unit wtf(String message, Throwable throwable, Map<String, Object> attributes)

        Sends an Assert log message.

        Parameters:
        message - the message to be logged
        throwable - a (nullable) throwable to be logged with the message
        attributes - a map of attributes to include only for this message.
      • wtf

        @JvmOverloads() final Unit wtf(String message, Throwable throwable)

        Sends an Assert log message.

        Parameters:
        message - the message to be logged
        throwable - a (nullable) throwable to be logged with the message
      • wtf

        @JvmOverloads() final Unit wtf(String message)

        Sends an Assert log message.

        Parameters:
        message - the message to be logged
      • log

        @JvmOverloads() final Unit log(Integer priority, String message, Throwable throwable, Map<String, Object> attributes)

        Sends a log message.

        Parameters:
        priority - the priority level (must be one of the Android Log.
        message - the message to be logged
        throwable - a (nullable) throwable to be logged with the message
        attributes - a map of attributes to include only for this message.
      • log

        @JvmOverloads() final Unit log(Integer priority, String message, Throwable throwable)

        Sends a log message.

        Parameters:
        priority - the priority level (must be one of the Android Log.
        message - the message to be logged
        throwable - a (nullable) throwable to be logged with the message
      • log

        @JvmOverloads() final Unit log(Integer priority, String message)

        Sends a log message.

        Parameters:
        priority - the priority level (must be one of the Android Log.
        message - the message to be logged
      • log

        @JvmOverloads() final Unit log(Integer priority, String message, String errorKind, String errorMessage, String errorStacktrace, Map<String, Object> attributes)

        Sends a log message with strings for error information.

        This method is meant for non-native or cross platform frameworks (such as React Native or Flutter) to send error information to Datadog. Although it can be used directly, it is recommended to use other methods declared on Logger.

        Parameters:
        priority - the priority level (must be one of the Android Log.
        message - the message to be logged
        errorKind - the kind of error to be logged with the message
        errorMessage - the message from the error to be logged with this message
        errorStacktrace - the stack trace from the error to be logged with this message
        attributes - a map of attributes to include only for this message.
      • log

        @JvmOverloads() final Unit log(Integer priority, String message, String errorKind, String errorMessage, String errorStacktrace)

        Sends a log message with strings for error information.

        This method is meant for non-native or cross platform frameworks (such as React Native or Flutter) to send error information to Datadog. Although it can be used directly, it is recommended to use other methods declared on Logger.

        Parameters:
        priority - the priority level (must be one of the Android Log.
        message - the message to be logged
        errorKind - the kind of error to be logged with the message
        errorMessage - the message from the error to be logged with this message
        errorStacktrace - the stack trace from the error to be logged with this message
      • addAttribute

         final Unit addAttribute(String key, Boolean value)

        Add a custom attribute to all future logs sent by this logger.

        Values can be nested up to 10 levels deep. Keys using more than 10 levels will be sanitized by SDK.

        Parameters:
        key - the key for this attribute
        value - the boolean value of this attribute
      • addAttribute

         final Unit addAttribute(String key, Integer value)

        Add a custom attribute to all future logs sent by this logger.

        Values can be nested up to 10 levels deep. Keys using more than 10 levels will be sanitized by SDK.

        Parameters:
        key - the key for this attribute
        value - the integer value of this attribute
      • addAttribute

         final Unit addAttribute(String key, Long value)

        Add a custom attribute to all future logs sent by this logger.

        Values can be nested up to 10 levels deep. Keys using more than 10 levels will be sanitized by SDK.

        Parameters:
        key - the key for this attribute
        value - the long value of this attribute
      • addAttribute

         final Unit addAttribute(String key, Float value)

        Add a custom attribute to all future logs sent by this logger.

        Values can be nested up to 10 levels deep. Keys using more than 10 levels will be sanitized by SDK.

        Parameters:
        key - the key for this attribute
        value - the float value of this attribute
      • addAttribute

         final Unit addAttribute(String key, Double value)

        Add a custom attribute to all future logs sent by this logger.

        Values can be nested up to 10 levels deep. Keys using more than 10 levels will be sanitized by SDK.

        Parameters:
        key - the key for this attribute
        value - the double value of this attribute
      • addAttribute

         final Unit addAttribute(String key, String value)

        Add a custom attribute to all future logs sent by this logger.

        Values can be nested up to 10 levels deep. Keys using more than 10 levels will be sanitized by SDK.

        Parameters:
        key - the key for this attribute
        value - the (nullable) String value of this attribute
      • addAttribute

         final Unit addAttribute(String key, Date value)

        Add a custom attribute to all future logs sent by this logger.

        Parameters:
        key - the key for this attribute
        value - the (nullable) Date value of this attribute
      • addAttribute

         final Unit addAttribute(String key, JsonObject value)

        Add a custom attribute to all future logs sent by this logger.

        Values can be nested up to 10 levels deep. Keys using more than 10 levels will be sanitized by SDK.

        Parameters:
        key - the key for this attribute
        value - the (nullable) JsonObject value of this attribute
      • addAttribute

         final Unit addAttribute(String key, JsonArray value)

        Add a custom attribute to all future logs sent by this logger.

        Values can be nested up to 10 levels deep. Keys using more than 10 levels will be sanitized by SDK.

        Parameters:
        key - the key for this attribute
        value - the (nullable) JsonArray value of this attribute
      • addAttribute

         final Unit addAttribute(String key, JSONObject value)

        Add a custom attribute to all future logs sent by this logger.

        Values can be nested up to 10 levels deep. Keys using more than 10 levels will be sanitized by SDK.

        Parameters:
        key - the key for this attribute
        value - the (nullable) JSONObject value of this attribute
      • addAttribute

         final Unit addAttribute(String key, JSONArray value)

        Add a custom attribute to all future logs sent by this logger.

        Values can be nested up to 10 levels deep. Keys using more than 10 levels will be sanitized by SDK.

        Parameters:
        key - the key for this attribute
        value - the (nullable) JSONArray value of this attribute
      • removeAttribute

         final Unit removeAttribute(String key)

        Remove a custom attribute from all future logs sent by this logger. Previous logs won't lose the attribute value associated with this key if they were created prior to this call.

        Parameters:
        key - the key of the attribute to remove
      • addTag

         final Unit addTag(String key, String value)

        Add a tag to all future logs sent by this logger. The tag will take the form "key:value".

        Tags must start with a letter and after that may contain the following characters: Alphanumerics, Underscores, Minuses, Colons, Periods, Slashes. Other special characters are converted to underscores. Tags must be lowercase, and can be at most 200 characters. If the tag you provide is longer, only the first 200 characters will be used.

        Parameters:
        key - the key for this tag
        value - the (non null) value of this tag
      • addTag

         final Unit addTag(String tag)

        Add a tag to all future logs sent by this logger.

        Tags must start with a letter and after that may contain the following characters: Alphanumerics, Underscores, Minuses, Colons, Periods, Slashes. Other special characters are converted to underscores. Tags must be lowercase, and can be at most 200 characters. If the tag you provide is longer, only the first 200 characters will be used.

        Parameters:
        tag - the (non null) tag
      • removeTag

         final Unit removeTag(String tag)

        Remove a tag from all future logs sent by this logger. Previous logs won't lose the this tag if they were created prior to this call.

        Parameters:
        tag - the tag to remove
      • removeTagsWithKey

         final Unit removeTagsWithKey(String key)

        Remove all tags with the given key from all future logs sent by this logger. Previous logs won't lose the this tag if they were created prior to this call.

        Parameters:
        key - the key of the tags to remove