> ## Documentation Index
> Fetch the complete documentation index at: https://developer.upsun.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Access your logs

> Increase your knowledge of how your apps are performing by accessing their container and activity logs.

This page covers activity logs and per-type container log files, accessed via the Console, CLI, or SSH. For a Console view of the last 24 hours of app and service logs across your whole environment, without SSH access, see [Log Explorer](https://developer.upsun.com/docs/observability/logs/log-explorer.md).

## Activity logs

Changes to your environments, such as deployments, cron jobs, and code or variable updates,
are each logged as activities.
You can access the logs either in the Console or using the [CLI](https://developer.upsun.com/cli.md):

> [tab] In the Console
>
> 1. Open the project you are interested in.
> 2. From the **Environment** menu, select an environment.
> 3. Click a recent activity from the activity feed or click **All** to see the complete history.
>
>    ![An activity feed within an environment](https://mintcdn.com/upsun-c9761871/7cK3KMJBgO7MXm_y/images/management-console/activity.png?fit=max\&auto=format\&n=7cK3KMJBgO7MXm_y\&q=85\&s=1dceac720590adb2e0d25fdc68c8d9d4)

> [tab] Using the CLI
>
> 1. Get a list of activities by running
>
>    ```bash theme={null}
>    upsun activity:list -e <ENVIRONMENT_NAME>
>    ```
>
>    Pass the `--start` flag to get activities from a specific date in the past.
>
> 2. To see details about the activity's state and timing, run
>
>    ```bash theme={null}
>    upsun activity:get <ACTIVITY_ID>
>    ```
>
>    Where `<ACTIVITY_ID>` comes from the list in step 1.
>
> 3. Get a log of any given activity by running
>
>    ```bash theme={null}
>    upsun activity:log <ACTIVITY_ID>
>    ```

If a running activity is stuck, you can [cancel the activity](https://developer.upsun.com/docs/environments/cancel-activity.md).

A scheduled [maintenance window](https://developer.upsun.com/docs/core-concepts/build-deploy.md#maintenance-window) run also appears here as a pending activity, about 5 days before it runs.

### Sharing activity logs

When trying to identify and resolve failures, it can often help to have another person's perspective.
Troubleshoot collaboratively by sharing the logs of specific activities.

To share a log, open the log and click  **Copy URL**.

Share specific lines in the log on clicking the line number.
To select multiple lines, hold <kbd>Shift</kbd>.
After selecting multiple lines,
hovering on the next unselected line gives you the amount of time that passed between the selected lines.

![An activity log with multiple lines selected showing the duration of part of the activity](https://mintcdn.com/upsun-c9761871/7cK3KMJBgO7MXm_y/images/management-console/activity-lines.png?fit=max\&auto=format\&n=7cK3KMJBgO7MXm_y\&q=85\&s=043b7c8acc0b9ebcc8b7fe2d8fc318e1)

## Container logs

Events that occur within an app container are logged within that container.
The logs can be written to, but you should do so only with standard logging mechanisms.
If your app has its own logging mechanism, use it to write to a dedicated logs [mount](https://developer.upsun.com/docs/configure-apps/image-properties/mounts.md).

To access the logs of various types of events:

> [tab] Using the CLI
>
> Use the `upsun log` command and specify the type of log you want.
> For example, to get the access log, run:
>
> ```bash theme={null}
> upsun log -e <ENVIRONMENT_NAME> access
> ```
>
> To get other logs, just replace `access` with the [type of log](#types-of-container-logs).
> To view more lines, use the `--lines` flag.

> [tab] Using SSH directly
>
> 1. Access the container by running
>
>    ```bash theme={null}
>    upsun ssh -e <ENVIRONMENT_NAME>
>    ```
>
> 2. Change to the right directory by running `cd /var/log`.
>    If you're on a Dedicated Gen 2 cluster, run
>
>    ```bash theme={null}
>    cd /var/log/upsun/<APP_NAME>/
>    ```
>
> 3. Read the desired log, such as by running `tail access.log`.

All log files are trimmed to 100 MB automatically.
If you need larger logs, set up a [cron job](https://developer.upsun.com/docs/configure-apps/image-properties/crons.md) to upload them to third-party storage.
See an example of [uploading logs to Amazon S3](https://gitlab.com/contextualcode/platformsh-store-logs-at-s3) from Contextual Code.

### Types of container logs

| Type | Always present | Description |
| - | - | - |
| `access` | Yes | The raw access log for the nginx instance running on the container. It doesn't include requests that are redirected or cached by the [router](https://developer.upsun.com/docs/routes). |
| `app` | Yes | All log messages generated by the app including language errors and exceptions. |
| `cron` | No | The output of cron jobs. Only exists after a cron job has run. |
| `deploy` | No | The output of the [`deploy` hook](https://developer.upsun.com/docs/configure-apps/hooks/hooks-comparison#deploy-hook). Only exists after a `deploy` hook has run. |
| `dns` | Yes | All DNS queries made by processes in the container (such as the app and cron jobs). |
| `error` | Yes | nginx-level errors that occur once nginx has fully started such as HTTP errors for missing directories and excluded file types. |
| `nginx/error` | No | All nginx startup log messages. Only useful when debugging possible nginx configuration errors. Not currently available using the `upsun log` command. |
| `php.access` | No | A record of all requests to the PHP service. See [PHP access record format](#php-access-record-format). |
| `post-deploy` | No | The output of the [`post_deploy` hook](https://developer.upsun.com/docs/configure-apps/hooks/hooks-comparison#post-deploy-hook). Only exists after a `post_deploy` hook has run. |
| `syslog` | Yes | General system-wide logs. |

#### PHP access record format

The formatting of `php.access.log` is determined by the PHP settings.
To determine the format, run the following:

```bash theme={null}
upsun ssh cat -n /etc/php/<PHP_VERSION>-zts/fpm/php-fpm.conf | grep "access.format"
```

You get a response such as the following:

```bash theme={null}
Connection to ssh.eu.platform.sh closed.
access.format = "%{%FT%TZ}t %m %s %{mili}d ms %{kilo}M kB %C%% %{REQUEST_URI}e"
```

See what [each value in this string means](https://www.php.net/manual/en/install.fpm.configuration.php#access-format).

## Timezones

UTC is the default timezone for all logs.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.