Every time record log in file

Registered by Daisuke Fujita

The --log-file option is effective to record log of the operation,
but is not effective for an investigation because the gathered information is insufficient.
Therefore, this option is not so useful for troubleshooting.

Implementing the following in this BP.
  1. Recording the operation history to log-file that specified by configuration-file(ex. clouds.yaml)
    Therefore, saving the log is to simple because every account can set a log-file.

  2. The recorded information includes following;
    if log level is "info" set, following items are logged;
      cloud name
      user name
      project name
      CLI start time (logging start time)
      CLI end time
      CLI argments
      CLI return value
      and, more info messages.

    if log level is "debug" set, following items are logged;
      cloud name
      user name
      project name
      CLI start time (logging start time)
      CLI end time
      CLI argments
      CLI return value
      API request header/body
      API response header/body
      and, more debug messages.

    if log level is not set, or other value set, that set warning level(default).

Recording the user operation, it can identify the change of the resource and it becomes useful information for troubleshooting.

For more details, refer to the following;

  Following is a sample config file.

  cloud.yaml
  -----------
  clouds:
    devstack:
      auth:
        auth_url: http://192.168.122.182:5000/v2.0
        project_name: admin
        username: admin
        password: password
      region_name: RegionOne
      cli_logging: # [1]
        logging: TRUE # [2]
        file: /home/stack/openstackclient.log # [3]
        log_level: info # [4]
  -----------

  [1] When it is not set, or other values are set, the logging disable.
  [2] When it is not set, or set false, or other values are set, the logging disable.
  [3] Set full-path of CLI logging file.
  [4] Set one from following;
        info, debug
          if log level is not set, or other value set, that set warning level(default).

  Following is a sample executed CLI.

  $ cat clouds.yaml
  clouds:
    devstack:
      auth:
        auth_url: http://192.168.122.182:5000/v2.0
        project_name: admin
        username: admin
        password: password
      region_name: RegionOne
      cli_logging:
        logging: TRUE
        file: /home/stack/openstackclient.log
        log_level: info
  $
  $ openstack --os-cloud devstack network list
  +--------------------------------------+--------------+--------------------------------------+
  | ID | Name | Subnets |
  +--------------------------------------+--------------+--------------------------------------+
  | 6bf9ebf0-9046-4a6d-a984-269da7cd96d1 | test-net-001 | |
  | 85fadf8e-0686-4a94-8846-cc9b70d6ad31 | test-net-002 | b3280f73-10de-46ac-88b8-b0f945a6d9c6 |
  | b8e24f8e-e329-458f-9635-35543117f8ac | private | a5eb3478-7126-4c76-a7df-b384233b88dc |
  | d927ca95-e145-4150-8a9d-abc54715f568 | test-net-003 | |
  | f427692e-01f9-45d2-8088-2dcb37a3cd7c | public | 58047d99-8a29-4ede-99c2-39b8987717d3 |
  +--------------------------------------+--------------+--------------------------------------+
  $
  $ cat /home/stack/openstackclient.log
  2015-05-28 19:45:38.906 14826 INFO openstackclient.shell [devstack admin admin] START with options: ['--os-cloud', 'devstack', 'network', 'list']
  2015-05-28 19:45:38.979 14826 INFO openstackclient.shell [devstack admin admin] command: network list -> openstackclient.network.v2.network.ListNetwork
  2015-05-28 19:45:38.980 14826 INFO openstackclient.common.clientmanager [devstack admin admin] Using auth plugin: osc_password
  2015-05-28 19:45:39.335 14826 INFO openstackclient.shell [devstack admin admin] END return value: 0
  $

  The log format referred to 'logging_context_format_string' of oslo_log/_options.py

  oslo_log/_options.py
  --------------------
  log_opts = [
      cfg.StrOpt('logging_context_format_string',
                 default='%(asctime)s.%(msecs)03d %(process)d %(levelname)s '
                         '%(name)s [%(request_id)s %(user_identity)s] '
                         '%(instance)s%(message)s',
                 help='Format string to use for log messages with context.'),
  --------------------

Blueprint information

Status:
Complete
Approver:
Steve Martinelli
Priority:
Medium
Drafter:
Daisuke Fujita
Direction:
Approved
Assignee:
Daisuke Fujita
Definition:
New
Series goal:
None
Implementation:
Implemented
Milestone target:
None
Started by
Steve Martinelli
Completed by
Steve Martinelli

Related branches

Sprints

Whiteboard

Gerrit topic: https://review.openstack.org/#q,topic:bp/every-time-record-log-in-file,n,z

Addressed by: https://review.openstack.org/186720
    Set up every time record log in file

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.