# Standard Logging and Response JSON
###### tags: `Services Architecture`
:::info
Penerapan **standard logging** yang akan diterapkan pada **semua services**, standard penulisan `code` untuk `stdout`
:::
## Standard Logging
### Contoh Output Logging
```json=
{
"duration": "",
"event": "",
"level": "",
"method": "",
"input": "",
"output": "",
"msg": "",
"headers": "",
"ts": "",
"msg": "",
"service": "",
"version": "",
"instance": "",
"trace_id": "",
}
```
| No | Key | Value | Type | Example |
| --- | -------- | ----- | ----- |----- |
| 1 | **duration** | Berapa lama service berjalan.| **ms** |`3.2323ms` |
| 2 | **event** | incoming request, request processing, request ended, outgoing request (3rd party), outgoing response (3rd party) | **string** | outgoing request |
| 3 | **level** | INFO, DEBUG, ERROR | **string** | INFO |
| 4 | **method** | functions / methods name | **string** | SaveFCMDeviceIdEnpoint |
| 5 | **input** | payload requests | **applications/json** | |
| 6 | **output** | result services | **applications/json** | | |
| 7 | **headers** | all headers | **objects** | | |
| 8 | **ts** | int | **int** | | |
| 9 | **msg** | string | **string** | pesan yang mau disampaikan, baik lisan, maupun tertulis |
| 10 | **service** | services name |**string** | `idm`, `notification`, |
| 11 | **version** | version apps/services |**string** | v2.10.21 | |
| 12 | **instance** | hostname |**string** | `ut-idm-{random}` | |
| 13 | **trace_id** | uuid |**string** | uuid | |
## Response JSON
```json=
{
"code": 200
"trace_id": "09dc99d7-4116-4102-b6eb-b7a864594883"
"message": "Data berhasil disimpan"
"data": {
"username": "kunbudiharta",
"email": "kun.budiharta@gmail.com",
"name": "Kun Budiharta",
"address": "Jl. Penerangan No. 41A, Grogol Petamburan, Jakarta Barat",
"zipcode": 11054
}
}
```
:::warning
**Note** :
200, 30x, 40x
:::
:::success
#### :+1: **SUCCESS**
HTTP_200: `200 OK`
HTTP_201: `201 Created`
HTTP_202: `202 Accepted`
HTTP_203: `203 Non-Authoritative Information`
HTTP_204: `204 No Content`
HTTP_205: `205 Reset Content`
HTTP_206: `206 Partial Content`
HTTP_207: `207 Multi-Status`
HTTP_208: `208 Already Reported`
HTTP_226: `226 IM Used`
:::
:::warning
#### :grey_exclamation: **WARNING**
HTTP_300: `300 Multiple Choices`
HTTP_301: `301 Moved Permanently`
HTTP_302: `302 Found`
HTTP_303: `303 See Other`
HTTP_304: `304 Not Modified`
HTTP_305: `305 Use Proxy`
HTTP_307: `307 Temporary Redirect`
HTTP_308: `308 Permanent Redirect`
:::
:::danger
#### :exclamation: **ERROR**
HTTP_400: `400 Bad Request`
HTTP_401: `401 Unauthorized`
HTTP_402: `402 Payment Required`
HTTP_403: `403 Forbidden`
HTTP_404: `404 Not Found`
HTTP_405: `405 Method Not Allowed`
HTTP_406: `406 Not Acceptable`
HTTP_407: `407 Proxy Authentication Required`
HTTP_408: `408 Request Time-out`
HTTP_409: `409 Conflict`
:::