# LogRecord

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Ctors](https://developer.android.com/reference/java/util/logging/LogRecord#pubctors)\|[Methods](https://developer.android.com/reference/java/util/logging/LogRecord#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/java/util/logging/LogRecord#inhmethods)  

# LogRecord

`
public


class
LogRecord
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


implements

`[Serializable](https://developer.android.com/reference/java/io/Serializable)`


`

|---|-----------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | java.util.logging.LogRecord |

<br />

*** ** * ** ***

LogRecord objects are used to pass logging requests between the logging framework and individual log Handlers.

When a LogRecord is passed into the logging framework it logically belongs to the framework and should no longer be used or updated by the client application.

Note that if the client application has not specified an explicit source method name and source class name, then the LogRecord class will infer them automatically when they are first accessed (due to a call on getSourceMethodName or getSourceClassName) by analyzing the call stack. Therefore, if a logging Handler wants to pass off a LogRecord to another thread, or to transmit it over RMI, and if it wishes to subsequently obtain method name or class name information it should call one of getSourceClassName or getSourceMethodName to force the values to be filled in.

**Serialization notes:**

- The LogRecord class is serializable.
- Because objects in the parameters array may not be serializable, during serialization all objects in the parameters array are written as the corresponding Strings (using Object.toString).
- The ResourceBundle is not transmitted as part of the serialized form, but the resource bundle name is, and the recipient object's readObject method will attempt to locate a suitable resource bundle.

<br />

## Summary

|                                                                                                                                                                           ### Public constructors                                                                                                                                                                           ||
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[LogRecord](https://developer.android.com/reference/java/util/logging/LogRecord#LogRecord(java.util.logging.Level,%20java.lang.String))`(`[Level](https://developer.android.com/reference/java/util/logging/Level)` level, `[String](https://developer.android.com/reference/java/lang/String)` msg) ` Construct a LogRecord with the given level and message values. |

|                                                                                                                                                                                      ### Public methods                                                                                                                                                                                      ||
|---------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[Level](https://developer.android.com/reference/java/util/logging/Level)           | ` `[getLevel](https://developer.android.com/reference/java/util/logging/LogRecord#getLevel())`() ` Get the logging message level, for example Level.SEVERE.                                                                                                                                           |
| ` `[String](https://developer.android.com/reference/java/lang/String)                 | ` `[getLoggerName](https://developer.android.com/reference/java/util/logging/LogRecord#getLoggerName())`() ` Get the source Logger's name.                                                                                                                                                            |
| ` `[String](https://developer.android.com/reference/java/lang/String)                 | ` `[getMessage](https://developer.android.com/reference/java/util/logging/LogRecord#getMessage())`() ` Get the "raw" log message, before localization or formatting.                                                                                                                                  |
| ` long`                                                                               | ` `[getMillis](https://developer.android.com/reference/java/util/logging/LogRecord#getMillis())`() ` Get event time in milliseconds since 1970.                                                                                                                                                       |
| ` `[Object[]](https://developer.android.com/reference/java/lang/Object)               | ` `[getParameters](https://developer.android.com/reference/java/util/logging/LogRecord#getParameters())`() ` Get the parameters to the log message.                                                                                                                                                   |
| ` `[ResourceBundle](https://developer.android.com/reference/java/util/ResourceBundle) | ` `[getResourceBundle](https://developer.android.com/reference/java/util/logging/LogRecord#getResourceBundle())`() ` Get the localization resource bundle This is the ResourceBundle that should be used to localize the message string before formatting it.                                         |
| ` `[String](https://developer.android.com/reference/java/lang/String)                 | ` `[getResourceBundleName](https://developer.android.com/reference/java/util/logging/LogRecord#getResourceBundleName())`() ` Get the localization resource bundle name This is the name for the ResourceBundle that should be used to localize the message string before formatting it.               |
| ` long`                                                                               | ` `[getSequenceNumber](https://developer.android.com/reference/java/util/logging/LogRecord#getSequenceNumber())`() ` Get the sequence number.                                                                                                                                                         |
| ` `[String](https://developer.android.com/reference/java/lang/String)                 | ` `[getSourceClassName](https://developer.android.com/reference/java/util/logging/LogRecord#getSourceClassName())`() ` Get the name of the class that (allegedly) issued the logging request.                                                                                                         |
| ` `[String](https://developer.android.com/reference/java/lang/String)                 | ` `[getSourceMethodName](https://developer.android.com/reference/java/util/logging/LogRecord#getSourceMethodName())`() ` Get the name of the method that (allegedly) issued the logging request.                                                                                                      |
| ` int`                                                                                | ` `[getThreadID](https://developer.android.com/reference/java/util/logging/LogRecord#getThreadID())`() ` Get an identifier for the thread where the message originated.                                                                                                                               |
| ` `[Throwable](https://developer.android.com/reference/java/lang/Throwable)           | ` `[getThrown](https://developer.android.com/reference/java/util/logging/LogRecord#getThrown())`() ` Get any throwable associated with the log record.                                                                                                                                                |
| ` void`                                                                               | ` `[setLevel](https://developer.android.com/reference/java/util/logging/LogRecord#setLevel(java.util.logging.Level))`(`[Level](https://developer.android.com/reference/java/util/logging/Level)` level) ` Set the logging message level, for example Level.SEVERE.                                    |
| ` void`                                                                               | ` `[setLoggerName](https://developer.android.com/reference/java/util/logging/LogRecord#setLoggerName(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` name) ` Set the source Logger's name.                                                                   |
| ` void`                                                                               | ` `[setMessage](https://developer.android.com/reference/java/util/logging/LogRecord#setMessage(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` message) ` Set the "raw" log message, before localization or formatting.                                      |
| ` void`                                                                               | ` `[setMillis](https://developer.android.com/reference/java/util/logging/LogRecord#setMillis(long))`(long millis) ` Set event time.                                                                                                                                                                   |
| ` void`                                                                               | ` `[setParameters](https://developer.android.com/reference/java/util/logging/LogRecord#setParameters(java.lang.Object[]))`(`[Object[]](https://developer.android.com/reference/java/lang/Object)` parameters) ` Set the parameters to the log message.                                                |
| ` void`                                                                               | ` `[setResourceBundle](https://developer.android.com/reference/java/util/logging/LogRecord#setResourceBundle(java.util.ResourceBundle))`(`[ResourceBundle](https://developer.android.com/reference/java/util/ResourceBundle)` bundle) ` Set the localization resource bundle.                         |
| ` void`                                                                               | ` `[setResourceBundleName](https://developer.android.com/reference/java/util/logging/LogRecord#setResourceBundleName(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` name) ` Set the localization resource bundle name.                                      |
| ` void`                                                                               | ` `[setSequenceNumber](https://developer.android.com/reference/java/util/logging/LogRecord#setSequenceNumber(long))`(long seq) ` Set the sequence number.                                                                                                                                             |
| ` void`                                                                               | ` `[setSourceClassName](https://developer.android.com/reference/java/util/logging/LogRecord#setSourceClassName(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` sourceClassName) ` Set the name of the class that (allegedly) issued the logging request.     |
| ` void`                                                                               | ` `[setSourceMethodName](https://developer.android.com/reference/java/util/logging/LogRecord#setSourceMethodName(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` sourceMethodName) ` Set the name of the method that (allegedly) issued the logging request. |
| ` void`                                                                               | ` `[setThreadID](https://developer.android.com/reference/java/util/logging/LogRecord#setThreadID(int))`(int threadID) ` Set an identifier for the thread where the message originated.                                                                                                                |
| ` void`                                                                               | ` `[setThrown](https://developer.android.com/reference/java/util/logging/LogRecord#setThrown(java.lang.Throwable))`(`[Throwable](https://developer.android.com/reference/java/lang/Throwable)` thrown) ` Set a throwable associated with the log event.                                               |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Public constructors

### LogRecord

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public LogRecord (Level level, 
                String msg)
```

Construct a LogRecord with the given level and message values.

The sequence property will be initialized with a new unique value. These sequence values are allocated in increasing order within a VM.

The millis property will be initialized to the current time.

The thread ID property will be initialized with a unique ID for the current thread.

All other properties will be initialized to "null".

<br />

|                                  Parameters                                   ||
|---------|----------------------------------------------------------------------|
| `level` | `Level`: a logging level value <br />                                |
| `msg`   | `String`: the raw non-localized logging message (may be null) <br /> |

## Public methods

### getLevel

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public Level getLevel ()
```

Get the logging message level, for example Level.SEVERE.

<br />

|                                                  Returns                                                   ||
|--------------------------------------------------------------------------|----------------------------------|
| [Level](https://developer.android.com/reference/java/util/logging/Level) | the logging message level <br /> |

### getLoggerName

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public String getLoggerName ()
```

Get the source Logger's name.

<br />

|                                                   Returns                                                   ||
|--------------------------------------------------------------------|-----------------------------------------|
| [String](https://developer.android.com/reference/java/lang/String) | source logger name (may be null) <br /> |

### getMessage

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public String getMessage ()
```

Get the "raw" log message, before localization or formatting.

May be null, which is equivalent to the empty string "".

This message may be either the final text or a localization key.

During formatting, if the source logger has a localization ResourceBundle and if that ResourceBundle has an entry for this message string, then the message string is replaced with the localized value.

<br />

|                                              Returns                                              ||
|--------------------------------------------------------------------|-------------------------------|
| [String](https://developer.android.com/reference/java/lang/String) | the raw message string <br /> |

### getMillis

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public long getMillis ()
```

Get event time in milliseconds since 1970.

<br />

|                    Returns                     ||
|--------|----------------------------------------|
| `long` | event time in millis since 1970 <br /> |

### getParameters

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public Object[] getParameters ()
```

Get the parameters to the log message.

<br />

|                                                                     Returns                                                                      ||
|----------------------------------------------------------------------|----------------------------------------------------------------------------|
| [Object[]](https://developer.android.com/reference/java/lang/Object) | the log message parameters. May be null if there are no parameters. <br /> |

### getResourceBundle

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public ResourceBundle getResourceBundle ()
```

Get the localization resource bundle

This is the ResourceBundle that should be used to localize the message string before formatting it. The result may be null if the message is not localizable, or if no suitable ResourceBundle is available.

<br />

|                                                           Returns                                                           ||
|------------------------------------------------------------------------------------|-----------------------------------------|
| [ResourceBundle](https://developer.android.com/reference/java/util/ResourceBundle) | the localization resource bundle <br /> |

### getResourceBundleName

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public String getResourceBundleName ()
```

Get the localization resource bundle name

This is the name for the ResourceBundle that should be used to localize the message string before formatting it. The result may be null if the message is not localizable.

<br />

|                                                     Returns                                                      ||
|--------------------------------------------------------------------|----------------------------------------------|
| [String](https://developer.android.com/reference/java/lang/String) | the localization resource bundle name <br /> |

### getSequenceNumber

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public long getSequenceNumber ()
```

Get the sequence number.

Sequence numbers are normally assigned in the LogRecord constructor, which assigns unique sequence numbers to each new LogRecord in increasing order.

<br />

|              Returns               ||
|--------|----------------------------|
| `long` | the sequence number <br /> |

### getSourceClassName

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public String getSourceClassName ()
```

Get the name of the class that (allegedly) issued the logging request.

Note that this sourceClassName is not verified and may be spoofed. This information may either have been provided as part of the logging call, or it may have been inferred automatically by the logging framework. In the latter case, the information may only be approximate and may in fact describe an earlier call on the stack frame.

May be null if no information could be obtained.

<br />

|                                             Returns                                              ||
|--------------------------------------------------------------------|------------------------------|
| [String](https://developer.android.com/reference/java/lang/String) | the source class name <br /> |

### getSourceMethodName

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public String getSourceMethodName ()
```

Get the name of the method that (allegedly) issued the logging request.

Note that this sourceMethodName is not verified and may be spoofed. This information may either have been provided as part of the logging call, or it may have been inferred automatically by the logging framework. In the latter case, the information may only be approximate and may in fact describe an earlier call on the stack frame.

May be null if no information could be obtained.

<br />

|                                              Returns                                              ||
|--------------------------------------------------------------------|-------------------------------|
| [String](https://developer.android.com/reference/java/lang/String) | the source method name <br /> |

### getThreadID

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public int getThreadID ()
```

Get an identifier for the thread where the message originated.

This is a thread identifier within the Java VM and may or may not map to any operating system ID.

<br />

|         Returns         ||
|-------|------------------|
| `int` | thread ID <br /> |

### getThrown

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public Throwable getThrown ()
```

Get any throwable associated with the log record.

If the event involved an exception, this will be the exception object. Otherwise null.

<br />

|                                           Returns                                            ||
|--------------------------------------------------------------------------|--------------------|
| [Throwable](https://developer.android.com/reference/java/lang/Throwable) | a throwable <br /> |

### setLevel

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setLevel (Level level)
```

Set the logging message level, for example Level.SEVERE.

<br />

|                     Parameters                     ||
|---------|-------------------------------------------|
| `level` | `Level`: the logging message level <br /> |

### setLoggerName

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setLoggerName (String name)
```

Set the source Logger's name.

<br />

|                          Parameters                           ||
|--------|-------------------------------------------------------|
| `name` | `String`: the source logger name (may be null) <br /> |

### setMessage

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setMessage (String message)
```

Set the "raw" log message, before localization or formatting.

<br />

|                            Parameters                            ||
|-----------|-------------------------------------------------------|
| `message` | `String`: the raw message string (may be null) <br /> |

### setMillis

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setMillis (long millis)
```

Set event time.

<br />

|                        Parameters                        ||
|----------|------------------------------------------------|
| `millis` | `long`: event time in millis since 1970 <br /> |

### setParameters

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setParameters (Object[] parameters)
```

Set the parameters to the log message.

<br />

|                                Parameters                                ||
|--------------|------------------------------------------------------------|
| `parameters` | `Object`: the log message parameters. (may be null) <br /> |

### setResourceBundle

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setResourceBundle (ResourceBundle bundle)
```

Set the localization resource bundle.

<br />

|                              Parameters                              ||
|----------|------------------------------------------------------------|
| `bundle` | `ResourceBundle`: localization bundle (may be null) <br /> |

### setResourceBundleName

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setResourceBundleName (String name)
```

Set the localization resource bundle name.

<br />

|                           Parameters                            ||
|--------|---------------------------------------------------------|
| `name` | `String`: localization bundle name (may be null) <br /> |

### setSequenceNumber

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setSequenceNumber (long seq)
```

Set the sequence number.

Sequence numbers are normally assigned in the LogRecord constructor, so it should not normally be necessary to use this method.

<br />

|                Parameters                 ||
|-------|------------------------------------|
| `seq` | `long`: the sequence number <br /> |

### setSourceClassName

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setSourceClassName (String sourceClassName)
```

Set the name of the class that (allegedly) issued the logging request.

<br />

|                               Parameters                                ||
|-------------------|------------------------------------------------------|
| `sourceClassName` | `String`: the source class name (may be null) <br /> |

### setSourceMethodName

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setSourceMethodName (String sourceMethodName)
```

Set the name of the method that (allegedly) issued the logging request.

<br />

|                                Parameters                                 ||
|--------------------|-------------------------------------------------------|
| `sourceMethodName` | `String`: the source method name (may be null) <br /> |

### setThreadID

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setThreadID (int threadID)
```

Set an identifier for the thread where the message originated.

<br />

|               Parameters                ||
|------------|-----------------------------|
| `threadID` | `int`: the thread ID <br /> |

### setThrown

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setThrown (Throwable thrown)
```

Set a throwable associated with the log event.

<br />

|                       Parameters                        ||
|----------|-----------------------------------------------|
| `thrown` | `Throwable`: a throwable (may be null) <br /> |