Skip to content

Commit

Permalink
Merge pull request #5504 from AzeemMuzammil/fb-access-log-bbe
Browse files Browse the repository at this point in the history
Update BBEs for AccessLog Improvements
  • Loading branch information
TharmiganK authored Aug 9, 2024
2 parents 246f296 + cab5906 commit 26445ad
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions examples/http-access-logs/Config.toml
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion examples/http-access-logs/http_access_logs.bal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ballerina/http;

type Album readonly & record {|
public type Album readonly & record {|
string title;
string artist;
|};
Expand Down
2 changes: 1 addition & 1 deletion examples/http-access-logs/http_access_logs.md
Original file line number Diff line number Diff line change
@@ -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. 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 :::

Expand Down
2 changes: 1 addition & 1 deletion examples/http-access-logs/http_access_logs.server.out
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 26445ad

Please sign in to comment.