# Migrating Version 1.x to 4.x

## Learn about migrating from version 1.x to 4.x

## [Migrating from `io.sentry:sentry` `1.x` to `io.sentry:sentry` `4.x`](#migrating-from-iosentrysentry-1x-to-iosentrysentry-4x)

Our update to the API follows the [Unified API](https://develop.sentry.dev/sdk/miscellaneous/unified-api/) more closely. It's a completely updated code base, written to support our Android SDK.

### [API Changes](#api-changes)

#### [Set tag](#set-tag)

*Previous*:

```java
Sentry.getContext().addTag("tagName", "tagValue");
```

*Updated*:

```java
Sentry.setTag("tagName", "tagValue");
```

#### [Capture custom exception](#capture-custom-exception)

*Previous*:

```java
try {
  int x = 1 / 0;
} catch (Exception e) {
  Sentry.capture(e);
}
```

*New*:

```java
try {
  int x = 1 / 0;
} catch (Exception e) {
  Sentry.captureException(e);
}
```

#### [Capture a message](#capture-a-message)

*Previous*:

```java
Sentry.capture("This is a test");
```

*New*:

```java
Sentry.captureMessage("This is a test"); // SentryLevel.INFO by default
Sentry.captureMessage("This is a test", SentryLevel.WARNING); // or specific level
```

#### [Breadcrumbs](#breadcrumbs)

*Previous*:

```java
Sentry.getContext().recordBreadcrumb(
  new BreadcrumbBuilder().setMessage("User made an action").build()
);
```

*New*:

```java
Sentry.addBreadcrumb("User made an action");
```

#### [User](#user)

*Previous*:

```java
Sentry.getContext().setUser(
  new UserBuilder().setEmail("hello@sentry.io").build()
);
```

*New*:

```java
User user = new User();
user.setEmail("hello@sentry.io");
Sentry.setUser(user);
```

#### [Set extra](#set-extra)

*Previous*:

```java
Sentry.getContext().addExtra("extra", "thing");
```

*New*:

```java
Sentry.setExtra("extra", "thing");
```

### [Removed Properties](#removed-properties)

Following configuration properties have been removed:

* `buffer.dir` - can be set with `SentryOptions#cacheDirPath`
* `buffer.size` - can be set with `SentryOptions#cacheDirSize`
* `buffer.flushtime` - can be set with `SentryOptions#flushTimeoutMillis`
* `buffer.shutdowntimeout`
* `buffer.gracefulshutdown`
* `async`
* `async.shutdowntimeout` - can be set with `SentryOptions#shutdownTimeout`
* `async.gracefulshutdown`
* `async.queuesize` - can be set with `SentryOptions#maxQueueSize`
* `async.threads`
* `async.priority`
* `compression`
* `maxmessagelength`
* `factory`
* `mdcTags`
* `extra` - can be set on the scope with `Scope#extra`

### [Property Name Changes](#property-name-changes)

Following properties cannot be set anymore through external configuration and have to be set directly on `SentryOptions` object when initializing Sentry:

* `sample.rate` - through `SentryOptions#sampleRate`
* `timeout` - through `SentryOptions#connectionTimeoutMillis` and `SentryOptions#readTimeoutMillis`

See [Configuration](/platforms/java/guides/jul/configuration/) page to find all available configuration properties.

#### [Tags](#tags)

*Previous*:

```properties
tags=tag1:value1,tag2:value2
```

*New*:

```properties
tags.tag1=value1
tags.tag2=value2
```

#### [“In Application” Stack Frames](#in-application-stack-frames)

```java
stacktrace.app.packages=com.mycompany,com.other.name
```

*New*:

```properties
in-app-includes=com.mycompany,com.other.name
```

There is also an option to exclude certain packages from stack traces:

```properties
in-app-excludes=com.packages.to.exclude
```
