> ## 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.

export const VariableBlock = ({name}) => {
  return <var spellCheck={false} title={`Replace '${name}' with your own data`}>{name}</var>;
};

export const ShareIcon = () => <svg width="24px" height="24px" style={{
  display: 'inline',
  verticalAlign: 'middle'
}}>
    <title id="share-icon">Share</title>
    <path fillRule="evenodd" clipRule="evenodd" d="M17 5C17 4.44772 17.4477 4 18 4C18.5523 4 19 4.44772 19 5C19 5.55228 18.5523 6 18 6C17.4477 6 17 5.55228 17 5ZM18 2C16.3431 2 15 3.34315 15 5C15 5.20611 15.0208 5.40737 15.0604 5.6018C15.0455 5.60908 15.0308 5.61675 15.0162 5.62483L7.84657 9.58848C7.83478 9.595 7.82317 9.60173 7.81174 9.60865C7.30835 9.22667 6.68065 9 6 9C4.34315 9 3 10.3431 3 12C3 13.6569 4.34315 15 6 15C6.69282 15 7.33078 14.7652 7.83862 14.3707C7.84014 14.3716 7.84166 14.3724 7.84319 14.3733L15.0128 18.3733C15.0285 18.3821 15.0444 18.3904 15.0604 18.3982C15.0208 18.5926 15 18.7939 15 19C15 20.6569 16.3431 22 18 22C19.6569 22 21 20.6569 21 19C21 17.3431 19.6569 16 18 16C17.2725 16 16.6055 16.2589 16.0861 16.6897C16.0548 16.6671 16.0218 16.646 15.9872 16.6267L8.92151 12.6847C8.97285 12.4648 9 12.2356 9 12C9 11.7531 8.97018 11.5132 8.91395 11.2837L15.9838 7.37516C16.0196 7.35536 16.0538 7.33369 16.0861 7.31033C16.6055 7.74106 17.2725 8 18 8C19.6569 8 21 6.65685 21 5C21 3.34315 19.6569 2 18 2ZM17 19C17 18.4477 17.4477 18 18 18C18.5523 18 19 18.4477 19 19C19 19.5523 18.5523 20 18 20C17.4477 20 17 19.5523 17 19ZM6 11C5.44772 11 5 11.4477 5 12C5 12.5523 5.44772 13 6 13C6.55228 13 7 12.5523 7 12C7 11.4477 6.55228 11 6 11Z" fill="current"></path>
  </svg>;

## 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](/cli):

<Tabs>
  <Tab title="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.

           <img src="https://mintcdn.com/upsun-c9761871/7cK3KMJBgO7MXm_y/images/management-console/activity.png?fit=max&auto=format&n=7cK3KMJBgO7MXm_y&q=85&s=1dceac720590adb2e0d25fdc68c8d9d4" alt="An activity feed within an environment" width="1600" height="1200" data-path="images/management-console/activity.png" />
  </Tab>

  <Tab title="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>
       ```
  </Tab>
</Tabs>

If a running activity is stuck, you can [cancel the activity](/docs/environments/cancel-activity).

### 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 <ShareIcon /> **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.

<img src="https://mintcdn.com/upsun-c9761871/7cK3KMJBgO7MXm_y/images/management-console/activity-lines.png?fit=max&auto=format&n=7cK3KMJBgO7MXm_y&q=85&s=043b7c8acc0b9ebcc8b7fe2d8fc318e1" alt="An activity log with multiple lines selected showing the duration of part of the activity" width="1493" height="898" data-path="images/management-console/activity-lines.png" />

## 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](/docs/configure-apps/image-properties/mounts).

To access the logs of various types of events:

<Tabs>
  <Tab title="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>

  <Tab title="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`.
  </Tab>
</Tabs>

All log files are trimmed to 100 MB automatically.
If you need larger logs, set up a [cron job](/docs/configure-apps/image-properties/crons) 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](/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](/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](/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.
