public class EventLog
extends Object



Access to the system diagnostic event record. System diagnostic events are used to record certain system-level events (such as garbage collection, activity manager state, system watchdogs, and other low level activity), which may be automatically collected and analyzed during system development.

This is not the main "logcat" debugging log (Log)! These diagnostic events are for system integrators, not application authors.

Events use integer tag codes corresponding to /system/etc/event-log-tags. They carry a payload of one or more int, long, or String values. The event-log-tags file defines the payload contents for each type code.

Summary

Nested classes

class EventLog.Event

A previously logged event read from the logs. 

Public methods

static int getTagCode(String name)

Get the event type tag code associated with an event name.

static String getTagName(int tag)

Get the name associated with an event type tag code.

static void readEvents(int[] tags, Collection<EventLog.Event> output)

Read events from the log, filtered by type.

static int writeEvent(int tag, String str)

Record an event log message.

static int writeEvent(int tag, int value)

Record an event log message.

static int writeEvent(int tag, float value)

Record an event log message.

static int writeEvent(int tag, Object... list)

Record an event log message.

static int writeEvent(int tag, long value)

Record an event log message.

Inherited methods

From class java.lang.Object

Object clone()

Creates and returns a copy of this object.

boolean equals(Object obj)

Indicates whether some other object is "equal to" this one.

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

final Class<?> getClass()

Returns the runtime class of this Object.

int hashCode()

Returns a hash code value for the object.

final void notify()

Wakes up a single thread that is waiting on this object's monitor.

final void notifyAll()

Wakes up all threads that are waiting on this object's monitor.

String toString()

Returns a string representation of the object.

final void wait(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(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()

Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

Public methods

getTagCode

Added in API level 8

public static int getTagCode (String name)

Get the event type tag code associated with an event name.

Parameters
name String: of event to look up
Returns
int the tag code, or -1 if no tag has that name

getTagName

Added in API level 8

public static String getTagName (int tag)

Get the name associated with an event type tag code.

Parameters
tag int: code to look up
Returns
String the name of the tag, or null if no tag has that number

readEvents

Added in API level 8

public static void readEvents (int[] tags, 
                Collection<EventLog.Event> output)

Read events from the log, filtered by type.

Parameters
tags int: to search for
output Collection: container to add events into
Throws
IOException if something goes wrong reading events

writeEvent

Added in API level 8

public static int writeEvent (int tag, 
                String str)

Record an event log message.

Parameters
tag int: The event type tag code
str String: A value to log
Returns
int The number of bytes written

writeEvent

Added in API level 8

public static int writeEvent (int tag, 
                int value)

Record an event log message.

Parameters
tag int: The event type tag code
value int: A value to log
Returns
int The number of bytes written

writeEvent

Added in API level 23

public static int writeEvent (int tag, 
                float value)

Record an event log message.

Parameters
tag int: The event type tag code
value float: A value to log
Returns
int The number of bytes written

writeEvent

Added in API level 8

public static int writeEvent (int tag, 
                Object... list)

Record an event log message.

Parameters
tag int: The event type tag code
list Object: A list of values to log
Returns
int The number of bytes written

writeEvent

Added in API level 8

public static int writeEvent (int tag, 
                long value)

Record an event log message.

Parameters
tag int: The event type tag code
value long: A value to log
Returns
int The number of bytes written

Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Last updated 2025-02-10 UTC.