From 62e8af814f9f32dc220b1f3d2ea457fbac327ee6 Mon Sep 17 00:00:00 2001 From: Azeem Muzammil Date: Thu, 11 Jul 2024 13:28:06 +0530 Subject: [PATCH 1/3] Update BBEs for AccessLog Improvements --- examples/http-access-logs/Config.toml | 4 ++++ examples/http-access-logs/http_access_logs.bal | 2 +- examples/http-access-logs/http_access_logs.md | 2 +- examples/http-access-logs/http_access_logs.server.out | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/examples/http-access-logs/Config.toml b/examples/http-access-logs/Config.toml index 4065733abe..71fc502ce0 100644 --- a/examples/http-access-logs/Config.toml +++ b/examples/http-access-logs/Config.toml @@ -1,5 +1,9 @@ [ballerina.http.accessLogConfig] # Enable printing access logs on the Console. The default value is `false`. console = true +# Specify the format of access logs. Options are `flat` or `json`. The default value is `flat`. +format = "flat" +# List of attributes to include in the access logs. This field is optional. +attributes = ["ip", "date_time", "request", "status", "response_body_size", "http_referrer", "http_user_agent"] # Specify the file path to save the access logs. This is optional. path = "testAccessLog.txt" diff --git a/examples/http-access-logs/http_access_logs.bal b/examples/http-access-logs/http_access_logs.bal index 653780467e..477c40d735 100644 --- a/examples/http-access-logs/http_access_logs.bal +++ b/examples/http-access-logs/http_access_logs.bal @@ -1,6 +1,6 @@ import ballerina/http; -type Album readonly & record {| +public type Album readonly & record {| string title; string artist; |}; diff --git a/examples/http-access-logs/http_access_logs.md b/examples/http-access-logs/http_access_logs.md index 78823d55ce..57ffcfb61c 100644 --- a/examples/http-access-logs/http_access_logs.md +++ b/examples/http-access-logs/http_access_logs.md @@ -1,6 +1,6 @@ # HTTP service - Access logs -Ballerina allows enabling HTTP access logs, which can be used to record the HTTP requests handled by the application. HTTP access logs are disabled by default. Set `console=true` under `ballerina.http.accessLogConfig` in the `Config.toml` file to enable them. Additionally, the `path` field can be used to specify the file path to save the access logs. +Ballerina allows enabling HTTP access logs, which can be used to record the HTTP requests handled by the application. HTTP access logs are disabled by default. To enable them, set `console=true` under `ballerina.http.accessLogConfig` in the `Config.toml` file. The optional `format` field allows you to specify the format of the access logs, with options being `flat` or `json`, defaulting to `flat`. You can also optionally specify which attributes to log by providing a list in the `attributes` field. Additionally, the optional `path` field can be used to specify the file path to save the access logs. ::: code http_access_logs.bal ::: diff --git a/examples/http-access-logs/http_access_logs.server.out b/examples/http-access-logs/http_access_logs.server.out index 7ead378b63..6a0ad5e8d2 100644 --- a/examples/http-access-logs/http_access_logs.server.out +++ b/examples/http-access-logs/http_access_logs.server.out @@ -1,3 +1,3 @@ $ bal run http_access_logs.bal ballerina: HTTP access log enabled -127.0.0.1 - - [15/Dec/2022:11:39:42 +0530] "GET /albums HTTP/1.1" 200 95 "-" "curl/7.79.1" +127.0.0.1 [11/Jul/2024:13:21:01.620 +0530] "GET /albums HTTP/1.1" 200 95 "-" "curl/8.4.0" From a047bc840c1e54fb09ac1d17f11d41f2ad537702 Mon Sep 17 00:00:00 2001 From: Azeem Muzammil Date: Tue, 16 Jul 2024 09:19:26 +0530 Subject: [PATCH 2/3] Address review comments --- examples/http-access-logs/http_access_logs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/http-access-logs/http_access_logs.md b/examples/http-access-logs/http_access_logs.md index 57ffcfb61c..d0f09e96ad 100644 --- a/examples/http-access-logs/http_access_logs.md +++ b/examples/http-access-logs/http_access_logs.md @@ -1,6 +1,6 @@ # HTTP service - Access logs -Ballerina allows enabling HTTP access logs, which can be used to record the HTTP requests handled by the application. HTTP access logs are disabled by default. To enable them, set `console=true` under `ballerina.http.accessLogConfig` in the `Config.toml` file. The optional `format` field allows you to specify the format of the access logs, with options being `flat` or `json`, defaulting to `flat`. You can also optionally specify which attributes to log by providing a list in the `attributes` field. Additionally, the optional `path` field can be used to specify the file path to save the access logs. +Ballerina allows enabling HTTP access logs, which can be used to record the HTTP requests handled by the application. HTTP access logs are disabled by default. To enable them, set `console=true` under `ballerina.http.accessLogConfig` in the `Config.toml` file. Additionally, the path field can be used to define the file path for saving the access logs, offering flexible log management. The log format can be specified using the optional `format` field, with `flat` and `json` as available options, defaulting to `flat`. Furthermore, you can customize the logged attributes by listing them in the optional `attributes` field. ::: code http_access_logs.bal ::: From cab590687da6adbbd2a6be2d6c211a32d74568fe Mon Sep 17 00:00:00 2001 From: Azeem Muzammil Date: Fri, 9 Aug 2024 10:25:53 +0530 Subject: [PATCH 3/3] Address review comments --- examples/http-access-logs/http_access_logs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/http-access-logs/http_access_logs.md b/examples/http-access-logs/http_access_logs.md index d0f09e96ad..1de7c9a570 100644 --- a/examples/http-access-logs/http_access_logs.md +++ b/examples/http-access-logs/http_access_logs.md @@ -1,6 +1,6 @@ # HTTP service - Access logs -Ballerina allows enabling HTTP access logs, which can be used to record the HTTP requests handled by the application. HTTP access logs are disabled by default. To enable them, set `console=true` under `ballerina.http.accessLogConfig` in the `Config.toml` file. Additionally, the path field can be used to define the file path for saving the access logs, offering flexible log management. The log format can be specified using the optional `format` field, with `flat` and `json` as available options, defaulting to `flat`. Furthermore, you can customize the logged attributes by listing them in the optional `attributes` field. +Ballerina allows enabling HTTP access logs, which can be used to record the HTTP requests handled by the application. HTTP access logs are disabled by default. Set `console=true` under `ballerina.http.accessLogConfig` in the `Config.toml` file to enable them. Additionally, the `path` field can be used to specify the file path to save the access logs. The log format can be specified as either `flat` or `json` using the optional `format` field (defaults to `flat`). Furthermore, you can customize the logged attributes using the optional `attributes` field. ::: code http_access_logs.bal :::