- Documentation
Torch Object Storage
SDK Reference
Go
Log Configuration
Log Configuration (Go SDK)
Log Configuration
Log Configuration (Go SDK)
Log Configuration (Go SDK)
The TOS Go SDK provides logging functionality. You can view request-related information by enabling logs.
Log Description
The SDK records relevant logs separately in each of the following scenarios.
Log Activation Methods
In the Go SDK, logging functionality can be injected by implementing the tos.Logger interface. This interface is currently compatible with the logrus logging library. "github.com/sirupsen/logrus"
"github.com/volcengine/ve-tos-golang-sdk/v2/tos"
accessKey = os.Getenv("TOS_ACCESS_KEY")
secretKey = os.Getenv("TOS_SECRET_KEY")
endpoint = "*** Provide your endpoint ***"
region = "*** Provide your region ***"
credential := tos.NewStaticCredentials(ak, sk)
client, err := tos.NewClientV2(endpoint, tos.WithCredentials(credential), tos.WithRegion(region), tos.WithLogger(logger))
fmt.Println("Error:", err)
Log Content Example
When the default log format is used, the log content is as follows.
time=2022-12-05T10:19:32+08:00 level=info msg=[tos] Response StatusCode:200, RequestId:950b488d553465ee638d5534-ac16898b, Cost:241 ms
time=2022-12-05T10:19:32+08:00 level=info msg=[tos] Response StatusCode:200, RequestId:950b488d553465ef638d5534-ac16898b, Cost:72 ms
time=2022-12-05T10:19:32+08:00 level=info msg=[tos] Response StatusCode:200, RequestId:950b488d553465f1638d5534-ac16898b, Cost:101 ms
Last updated: 2025.09.19 17:30:18