# Accessing device logs

The Logging Service API allows widgets to access mobile device logging events such as call logs, messaging logs, and data logs. You can use the Logging Service to create widgets that add, read, and delete logging events. For example, you can create widgets that:

- Automatically delete the records of received calls older than a specified number of days

- Create unique records of calls based on criteria such as call duration

- Provide useful information to mobile device users such as the number of MB of data sent and received for the day

### Accessing the API and supported methods

To create a service object for the Logging Service API, use `Service.Logging` to identify the service provider and `IDataSource` to identify the supported interface:

    var so = device.getServiceObject("Service.Logging", "IDataSource");

The `IDataSource` interface provides the following methods:

- `Add()`

  Use the `Add()` method to add an entry to the event log; for example, to create new types of application-specific log entries.

- `GetList()`

  Use the `GetList()` method to retrieve event details such as phone number or call duration from the event log.

- `Delete()`

  Use the `Delete()` method to delete an entry from the event log.

- `RequestNotification()`

  Use the `RequestNotification()` method to request notification of updates to the event log.

- `Cancel()`

  Use the `Cancel()` method to cancel an ongoing asynchronous call. This method is valid for any asynchronous call made through the Logging Service API.

### Using the service in a widget

To access and manage logs using the Logging Service API:

1. Create a service object for the API using `device.getServiceObject()`.

2. Define the tasks you want to perform and choose the correct methods for them.

3. Optionally, define how you want the results filtered.

4. Define functions to process the results.

5. Retrieve the results.

6. Process the results.

For the complete source of a sample widget that demonstrates how to use this service, see the full example.