# Log

Artifact: [androidx.media3:media3-common](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/common/util/Log.java+class:androidx.media3.common.util.Log)

*** ** * ** ***


```
@UnstableApi
public final class Log
```

<br />

*** ** * ** ***

Wrapper around `https://developer.android.com/reference/android/util/Log.html` which allows to set the log level and to specify a custom log output.

## Summary

| ### Nested types |
|---|
| `@https://developer.android.com/reference/java/lang/annotation/Documented.html @https://developer.android.com/reference/java/lang/annotation/Retention.html(value = https://developer.android.com/reference/java/lang/annotation/RetentionPolicy.html#SOURCE) @https://developer.android.com/reference/java/lang/annotation/Target.html(value = https://developer.android.com/reference/java/lang/annotation/ElementType.html#TYPE_USE) @https://developer.android.com/reference/androidx/annotation/IntDef(value = ) public annotation https://developer.android.com/reference/androidx/media3/common/util/Log.LogLevel` Log level for ExoPlayer logcat logging. |
| `public interface https://developer.android.com/reference/androidx/media3/common/util/Log.Logger` Interface for a logger that can output messages with a tag. |

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/androidx/media3/common/util/Log#LOG_LEVEL_ALL() = 0` Log level to log all messages. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/common/util/Log#LOG_LEVEL_ERROR() = 3` Log level to only log error messages. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/common/util/Log#LOG_LEVEL_INFO() = 1` Log level to only log informative, warning and error messages. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/common/util/Log#LOG_LEVEL_OFF() = 2147483647` Log level to disable all logging. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/common/util/Log#LOG_LEVEL_WARNING() = 2` Log level to only log warning and error messages. |

| ### Public fields |
|---|---|
| `static int` | `@https://developer.android.com/reference/androidx/annotation/GuardedBy(value = "lock") https://developer.android.com/reference/androidx/media3/common/util/Log#logLevel()` |

| ### Public methods |
|---|---|
| `static https://developer.android.com/reference/java/lang/String.html` | `@https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html https://developer.android.com/reference/androidx/media3/common/util/Log#appendThrowableString(java.lang.String,java.lang.Throwable)(https://developer.android.com/reference/java/lang/String.html message, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Throwable.html throwable)` Appends the result of `https://developer.android.com/reference/androidx/media3/common/util/Log#getThrowableString(java.lang.Throwable)` (if non-empty) to `message`. |
| `static void` | `@https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html https://developer.android.com/reference/androidx/media3/common/util/Log#d(java.lang.String,java.lang.String)(@https://developer.android.com/reference/androidx/annotation/Size(max = 23) https://developer.android.com/reference/java/lang/String.html tag, https://developer.android.com/reference/java/lang/String.html message)` Logs a debug-level message. |
| `static void` | `@https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html https://developer.android.com/reference/androidx/media3/common/util/Log#d(java.lang.String,java.lang.String,java.lang.Throwable)(@https://developer.android.com/reference/androidx/annotation/Size(max = 23) https://developer.android.com/reference/java/lang/String.html tag, https://developer.android.com/reference/java/lang/String.html message, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Throwable.html throwable)` Logs a debug-level message with an optional associated `https://developer.android.com/reference/java/lang/Throwable.html`. |
| `static void` | `@https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html https://developer.android.com/reference/androidx/media3/common/util/Log#e(java.lang.String,java.lang.String)(@https://developer.android.com/reference/androidx/annotation/Size(max = 23) https://developer.android.com/reference/java/lang/String.html tag, https://developer.android.com/reference/java/lang/String.html message)` Logs an error-level message. |
| `static void` | `@https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html https://developer.android.com/reference/androidx/media3/common/util/Log#e(java.lang.String,java.lang.String,java.lang.Throwable)(@https://developer.android.com/reference/androidx/annotation/Size(max = 23) https://developer.android.com/reference/java/lang/String.html tag, https://developer.android.com/reference/java/lang/String.html message, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Throwable.html throwable)` Logs an error-level message with an optional associated `https://developer.android.com/reference/java/lang/Throwable.html`. |
| `static int` | `@https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html @https://developer.android.com/reference/androidx/media3/common/util/Log.LogLevel https://developer.android.com/reference/androidx/media3/common/util/Log#getLogLevel()()` Returns current `https://developer.android.com/reference/androidx/media3/common/util/Log.LogLevel` for ExoPlayer logcat logging. |
| `static @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html` | `@https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html https://developer.android.com/reference/androidx/media3/common/util/Log#getThrowableString(java.lang.Throwable)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Throwable.html throwable)` Returns a string representation of a `https://developer.android.com/reference/java/lang/Throwable.html` suitable for logging, taking into account whether `https://developer.android.com/reference/androidx/media3/common/util/Log#setLogStackTraces(boolean)` stack trace logging} is enabled. |
| `static void` | `@https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html https://developer.android.com/reference/androidx/media3/common/util/Log#i(java.lang.String,java.lang.String)(@https://developer.android.com/reference/androidx/annotation/Size(max = 23) https://developer.android.com/reference/java/lang/String.html tag, https://developer.android.com/reference/java/lang/String.html message)` Logs an information-level message. |
| `static void` | `@https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html https://developer.android.com/reference/androidx/media3/common/util/Log#i(java.lang.String,java.lang.String,java.lang.Throwable)(@https://developer.android.com/reference/androidx/annotation/Size(max = 23) https://developer.android.com/reference/java/lang/String.html tag, https://developer.android.com/reference/java/lang/String.html message, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Throwable.html throwable)` Logs an information-level message with an optional associated `https://developer.android.com/reference/java/lang/Throwable.html`. |
| `static void` | `https://developer.android.com/reference/androidx/media3/common/util/Log#setLogLevel(int)(@https://developer.android.com/reference/androidx/media3/common/util/Log.LogLevel int logLevel)` Sets the `https://developer.android.com/reference/androidx/media3/common/util/Log.LogLevel` for ExoPlayer logcat logging. |
| `static void` | `https://developer.android.com/reference/androidx/media3/common/util/Log#setLogStackTraces(boolean)(boolean logStackTraces)` Sets whether stack traces of `https://developer.android.com/reference/java/lang/Throwable.html`s will be logged to logcat. |
| `static void` | `https://developer.android.com/reference/androidx/media3/common/util/Log#setLogger(androidx.media3.common.util.Log.Logger)(https://developer.android.com/reference/androidx/media3/common/util/Log.Logger logger)` Sets a custom `https://developer.android.com/reference/androidx/media3/common/util/Log.Logger` as the output. |
| `static void` | `@https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html https://developer.android.com/reference/androidx/media3/common/util/Log#w(java.lang.String,java.lang.String)(@https://developer.android.com/reference/androidx/annotation/Size(max = 23) https://developer.android.com/reference/java/lang/String.html tag, https://developer.android.com/reference/java/lang/String.html message)` Logs a warning-level message. |
| `static void` | `@https://checkerframework.org/api/org/checkerframework/dataflow/qual/Pure.html https://developer.android.com/reference/androidx/media3/common/util/Log#w(java.lang.String,java.lang.String,java.lang.Throwable)(@https://developer.android.com/reference/androidx/annotation/Size(max = 23) https://developer.android.com/reference/java/lang/String.html tag, https://developer.android.com/reference/java/lang/String.html message, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Throwable.html throwable)` Logs a warning-level message with an optional associated `https://developer.android.com/reference/java/lang/Throwable.html`.. |

## Constants

### LOG_LEVEL_ALL

```
public static final int LOG_LEVEL_ALL = 0
```

Log level to log all messages.

### LOG_LEVEL_ERROR

```
public static final int LOG_LEVEL_ERROR = 3
```

Log level to only log error messages.

### LOG_LEVEL_INFO

```
public static final int LOG_LEVEL_INFO = 1
```

Log level to only log informative, warning and error messages.

### LOG_LEVEL_OFF

```
public static final int LOG_LEVEL_OFF = 2147483647
```

Log level to disable all logging.

### LOG_LEVEL_WARNING

```
public static final int LOG_LEVEL_WARNING = 2
```

Log level to only log warning and error messages.

## Public fields

### logLevel

```
@GuardedBy(value = "lock")
public static int logLevel
```

## Public methods

### appendThrowableString

```
@Pure
public static String appendThrowableString(String message, @Nullable Throwable throwable)
```

Appends the result of `https://developer.android.com/reference/androidx/media3/common/util/Log#getThrowableString(java.lang.Throwable)` (if non-empty) to `message`.

### d

```
@Pure
public static void d(@Size(max = 23) String tag, String message)
```

Logs a debug-level message.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Size(max = 23) https://developer.android.com/reference/java/lang/String.html tag` | The tag of the message. |
| `https://developer.android.com/reference/java/lang/String.html message` | The message. |

### d

```
@Pure
public static void d(@Size(max = 23) String tag, String message, @Nullable Throwable throwable)
```

Logs a debug-level message with an optional associated `https://developer.android.com/reference/java/lang/Throwable.html`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Size(max = 23) https://developer.android.com/reference/java/lang/String.html tag` | The tag of the message. |
| `https://developer.android.com/reference/java/lang/String.html message` | The message. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Throwable.html throwable` | The `https://developer.android.com/reference/java/lang/Throwable.html` associated with the message, or null if not specified. |

### e

```
@Pure
public static void e(@Size(max = 23) String tag, String message)
```

Logs an error-level message.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Size(max = 23) https://developer.android.com/reference/java/lang/String.html tag` | The tag of the message. |
| `https://developer.android.com/reference/java/lang/String.html message` | The message. |

### e

```
@Pure
public static void e(@Size(max = 23) String tag, String message, @Nullable Throwable throwable)
```

Logs an error-level message with an optional associated `https://developer.android.com/reference/java/lang/Throwable.html`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Size(max = 23) https://developer.android.com/reference/java/lang/String.html tag` | The tag of the message. |
| `https://developer.android.com/reference/java/lang/String.html message` | The message. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Throwable.html throwable` | The `https://developer.android.com/reference/java/lang/Throwable.html` associated with the message, or null if not specified. |

### getLogLevel

```
@Pure
@Log.LogLevel
public static int getLogLevel()
```

Returns current `https://developer.android.com/reference/androidx/media3/common/util/Log.LogLevel` for ExoPlayer logcat logging.

### getThrowableString

```
@Pure
public static @Nullable String getThrowableString(@Nullable Throwable throwable)
```

Returns a string representation of a `https://developer.android.com/reference/java/lang/Throwable.html` suitable for logging, taking into account whether `https://developer.android.com/reference/androidx/media3/common/util/Log#setLogStackTraces(boolean)` stack trace logging} is enabled.

Stack trace logging may be unconditionally suppressed for some expected failure modes (e.g., `https://developer.android.com/reference/java/lang/Throwable.html` that are expected if the device doesn't have network connectivity) to avoid log spam.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Throwable.html throwable` | The `https://developer.android.com/reference/java/lang/Throwable.html`. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html` | The string representation of the `https://developer.android.com/reference/java/lang/Throwable.html`, or null if `throwable` is null. |

### i

```
@Pure
public static void i(@Size(max = 23) String tag, String message)
```

Logs an information-level message.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Size(max = 23) https://developer.android.com/reference/java/lang/String.html tag` | The tag of the message. |
| `https://developer.android.com/reference/java/lang/String.html message` | The message. |

### i

```
@Pure
public static void i(@Size(max = 23) String tag, String message, @Nullable Throwable throwable)
```

Logs an information-level message with an optional associated `https://developer.android.com/reference/java/lang/Throwable.html`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Size(max = 23) https://developer.android.com/reference/java/lang/String.html tag` | The tag of the message. |
| `https://developer.android.com/reference/java/lang/String.html message` | The message. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Throwable.html throwable` | The `https://developer.android.com/reference/java/lang/Throwable.html` associated with the message, or null if not specified. |

### setLogLevel

```
public static void setLogLevel(@Log.LogLevel int logLevel)
```

Sets the `https://developer.android.com/reference/androidx/media3/common/util/Log.LogLevel` for ExoPlayer logcat logging.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/common/util/Log.LogLevel int logLevel` | The new `https://developer.android.com/reference/androidx/media3/common/util/Log.LogLevel`. |

### setLogStackTraces

```
public static void setLogStackTraces(boolean logStackTraces)
```

Sets whether stack traces of `https://developer.android.com/reference/java/lang/Throwable.html`s will be logged to logcat. Stack trace logging is enabled by default.

| Parameters |
|---|---|
| `boolean logStackTraces` | Whether stack traces will be logged. |

### setLogger

```
public static void setLogger(Log.Logger logger)
```

Sets a custom `https://developer.android.com/reference/androidx/media3/common/util/Log.Logger` as the output.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/util/Log.Logger logger` | The `https://developer.android.com/reference/androidx/media3/common/util/Log.Logger`. |

### w

```
@Pure
public static void w(@Size(max = 23) String tag, String message)
```

Logs a warning-level message.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Size(max = 23) https://developer.android.com/reference/java/lang/String.html tag` | The tag of the message. |
| `https://developer.android.com/reference/java/lang/String.html message` | The message. |

### w

```
@Pure
public static void w(@Size(max = 23) String tag, String message, @Nullable Throwable throwable)
```

Logs a warning-level message with an optional associated `https://developer.android.com/reference/java/lang/Throwable.html`..

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Size(max = 23) https://developer.android.com/reference/java/lang/String.html tag` | The tag of the message. |
| `https://developer.android.com/reference/java/lang/String.html message` | The message. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Throwable.html throwable` | The `https://developer.android.com/reference/java/lang/Throwable.html` associated with the message, or null if not specified. |