The logging command is used to add, modify, query, or delete the logging configurations for a specified bucket.

Note For more information about logging, see Access logging.

Command syntax

  • Add or modify logging configurations
    ./ossutil logging --method put oss://bucket  oss://target-bucket/[prefix]

    If logging is disabled for the bucket, you can run this command to save access logs as objects in the bucket specified by the target-bucket parameter. However, if logging is enabled for the bucket, you can run this command to change the directory in which access logs are stored.

    The prefix parameter specifies the prefix of access logs and the directory where bucket access logs are stored. If this parameter is specified, ossutil saves access logs to the directory of the bucket specified by the target-bucket parameter. If this parameter is not specified, ossutil saves your access logs to the root directory of the bucket specified by the target-bucket parameter. For more information about log file naming conventions, see Set logging.

  • Obtain logging configurations
    ./ossutil logging --method get oss://bucket  [local_xml_file]

    The local_xml_file parameter specifies the name of the configuration file. If this parameter is specified, ossutil saves the obtained logging configurations as a local file. If this parameter is not specified, ossutil displays the obtained logging configurations.

  • Delete logging configurations
    ./ossutil logging --method delete oss://bucket

Examples

  • Add logging configurations
    ./ossutil logging --method put oss://bucket1  oss://bucket2/logging
  • Obtain logging configurations
    ./ossutil logging --method get oss://bucket1  /file/logging.xml
  • Delete logging configurations
    ./ossutil logging --method delete oss://bucket1

Common options

The following table describes the options you can add to the logging command.
Option Description
--method Specifies the HTTP request method. Valid values:
  • put: adds or modifies logging configurations.
  • get: obtains logging configurations.
  • delete: deletes logging configurations.
--loglevel Specifies the log level. The default value is null, indicating that no log files are generated. Valid values:
  • info: generates prompt logs.
  • debug: generates detailed logs that contain corresponding HTTP request and response information.
--proxy-host Specifies the URL of the proxy server. HTTP, HTTPS, and SOCKS5 are supported. An example of the URL is http://120.79. **.**:3128 or socks5://120.79. **. **:1080.
--proxy-user Specifies the username of the proxy server. The default value is null.
--proxy-pwd Specifies the password of the proxy server. The default value is null.
Note For more information about common options, see View all supported options.