# Quick Guide for Logging Configuration

This document outlines the log output standards and configurations for services built on the insureMO App Framework.

## Log Types

The system generates the following log types:

-   **Application Log (App Log):** Detailed logs for application activities.
-   **Business Log:** Records of business operations and transactions.
-   **Access Log:** Tracks users access and system interactions.
-   **Garbage Collection Log (GC Log):** Information on garbage collection processes.

## Log Standards

Our log standards ensure consistency across all log types by defining fields, file paths, index names, and more.

-   [Log Standard Documentation](https://docs.insuremo.com/common/doc_00000362)

## Log Configuration

### Disabling Log Files

Control log file generation using the following configurations:

-   **Disable Access Log File Output:** Prevent access log files from being written by setting the following property.

  ```properties
  server.tomcat.accesslog.enabled=false # default is true
  ```

-   **Disable Application Log File Output:** Stop the output of application log files using the following environment variable.

  ```properties
  LOG_FILE_ENABLED=false # default is true
  ```

-   **Disable Business Log File Output:** Halt the generation of business log files using the following environment variable.

  ```properties
  BUSINESS_LOG_FILE_ENABLED=false # default is true
  ```

### Controlling Log Output Format

-   **Console Output Format for App Log:** Control the JSON format output of app logs in the console using the following environment variable.

  ```properties
  IS_CONSOLE_LOG_JSON_FORMAT=Y # default is N
  ```

-   **Console Output Format for Access Log:** Control the JSON format output of access logs in the console by setting the following property.

  ```properties
  server.accesslog.console.enabled=true # default is false
  ```

### Log Output Configuration (Since ICS 25.02)

The following settings, available since ICS 25.02, allow you to control log output to the console in JSON format for app logs, business logs, GC logs, and access logs via the configuration center. If no configuration is provided, logs will be outputted to files in JSON format.

**Platform Configuration Center:**

To enable console output, set the following property:

```properties
public/platform/logging.output.mode=console
```

To disable specific log types from being outputted, set the corresponding property to `false`:

```properties
public/platform/logging.output.access.enabled=false
public/platform/logging.output.business.enabled=false
public/platform/logging.output.gc.enabled=false
```

**Tenant Configuration Center:**

Configure these settings under the `public` path in the tenant configuration center. For example:

```properties
public/logging.output.mode=console
```

To disable specific log types from being outputted, set the corresponding property to `false`:

```properties
public/logging.output.access.enabled=false
public/logging.output.business.enabled=false
public/logging.output.gc.enabled=false
```


### Field Configuration

-   **Vendor**

  The `vendor` field is populated based on the following order of precedence:

  1.  `VENDOR` environment variable.
  2.  `NAMESPACE` environment variable (if `VENDOR` is not set).
  3.  Default value: `appframework` (if neither `VENDOR` nor `NAMESPACE` is set).

-   **Provider**

  The `provider` field is populated based on the following order of precedence:

  1.  `PROVIDER` environment variable.
  2.  `NAMESPACE` environment variable (if `PROVIDER` is not set).
  3.  Default value: `appframework` (if neither `PROVIDER` nor `NAMESPACE` is set).

## Log Files

### File Generation Path (LOG HOME)

-   **Access Log:** `/app/logs`
-   **Application Log:** `/app/logs`
-   **Business Log:** `/app/logs`

### File Names

-   **Access Log:** `access_json.log`
-   **Application Log:** `runtime_json.log`
-   **Business Log:** `business_json.log`

## Additional Settings

### Log File Rotation

-   **Enable Log File Rotation for Access Log:** Enable log rotation for access logs using the following property.

  ```properties
  server.tomcat.accesslog.rotate=true # default is true
  ```

-   **Enable Log File Rotation for App Log:** Enable log rotation for app logs using the following environment variable.

  ```properties
  LOG_FILE_ROTATE=true # default is false
  ```

-   **Enable Log File Rotation for Business Log:** Enable log rotation for business logs using the following environment variable.

  ```properties
  LOG_FILE_ROTATE=true # default is false
  ```
