# Enable user activity logging

User activity logging is a feature that allows you to log user activities. Below is an example of logged user actions:

```CONSOLE
$ tail -f /tmp/datalore/datalore.log
```

```JSON
{"@timestamp":"2022-10-11T14:46:14.594+02:00","@version":"1","message":"Audit logging event","logger_name":"audit","thread_name":"Computation edt_0_0","level":"TRACE","level_value":5000,"id":"B9otorSZuP2n2vyTHCkhLe","timestamp":"1665492374594","event_type":"run_cell","user_id":"pEoHIeNPj4DE43XInXC5OV","cell_content":"print(123)","file_id":"pEoHIeNPj4DE43XInXC5OV\/cEFzZVm3xAYFg3nvWeZqnT"}
```

Procedure: Enable user activity logging

1. Make a local copy of the `logback.xml` config file that can be found at `/opt/datalore/tomcat/conf/logback.xml` inside the server container.

```YAML
services:
  datalore:
    ...
    volumes:
      ...
     - "./logback.xml:/opt/datalore/tomcat/conf/logback.xml"
```

2. Edit the file copy. Choose a logback [appender](https://logback.qos.ch/manual/appenders.html), add the `net.logstash.logback.encoder.LogstashEncoder` encoder for it and specify your logger configuration in place of `<logger name="audit" level="OFF"/>` as shown in the example below.

```XML
<configuration>
    ...
    <appender name="AUDIT" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <file>/tmp/datalore/datalore.log</file>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <fileNamePattern>datalore.%d{yyyy-MM-dd}.log</fileNamePattern>
            <maxHistory>30</maxHistory>
            <totalSizeCap>30GB</totalSizeCap>
        </rollingPolicy>
        <encoder class="net.logstash.logback.encoder.LogstashEncoder"/>
    </appender>
    <logger name="audit" level="ALL" additivity="false">
        <appender-ref ref="AUDIT"/>
    </logger>
    ...
</configuration>
```

3. Replace the content of the original `logback.xml` file (same directory from which you run Docker Compose) with the content of the edited copy.

> **Note:**
> All logs are saved to `/tmp/datalore/datalore.log`. This file will be created inside the container. Make sure the folder with your logs is in a persistent volume so they are saved after the pod is restarted.

