如何为Fabric中的特定模块设置调试级别?

问题描述 投票:2回答:3

谁能告诉我如何通过更改docker文件中的env变量来设置结构中特定模块的调试级别?在对等日志中,我们可以看到

2017-07-24 03:44:44.787 UTC [flogging] setModuleLevel - > DEBU 189模块'msp / identity'记录器启用日志级别'警告'

2017-07-24 03:44:44.787 UTC [flogging] setModuleLevel - > DEBU 18a模块'msp'记录器启用日志级别'警告'

2017-07-24 03:44:44.787 UTC [flogging] setModuleLevel - > DEBU 18b模块'configvalues / msp'记录器启用日志级别'警告'

2017-07-24 03:44:44.787 UTC [flogging] setModuleLevel - > DEBU 18c模块'peer / gossip / mcs'记录器启用日志级别'警告'

2017-07-24 03:44:44.787 UTC [flogging] setModuleLevel - > DEBU 18d模块'八卦/状态'记录器启用日志级别'警告'

我想让他们中的一些人处于调试模式,如何实现呢?仅供参考,我试图设置GOSSIP_SERVICE_LOGGING_LEVEL=DEBUGGRPC_LOGGING_LEVEL=DEBUG来使模块八卦/服务和grpc在调试模式下,但它不起作用:( ...

hyperledger hyperledger-fabric
3个回答
2
投票

要更改模块的日志记录级别,您需要在core.yaml文件中进行更改:

###############################################################################
#
#    LOGGING section
#
###############################################################################
logging:

    # Default logging levels are specified here.

    # Valid logging levels are case-insensitive strings chosen from

    #     CRITICAL | ERROR | WARNING | NOTICE | INFO | DEBUG

    # The overall default logging level can be specified in various ways,
    # listed below from strongest to weakest:
    #
    # 1. The --logging-level=<level> command line option overrides all other
    #    default specifications.
    #
    # 2. The environment variable CORE_LOGGING_LEVEL otherwise applies to
    #    all peer commands if defined as a non-empty string.
    #
    # 3. The value of peer that directly follows in this file. It can also
    #    be set via the environment variable CORE_LOGGING_PEER.
    #
    # If no overall default level is provided via any of the above methods,
    # the peer will default to INFO (the value of defaultLevel in
    # common/flogging/logging.go)

    # Default for all modules running within the scope of a peer.
    # Note: this value is only used when --logging-level or CORE_LOGGING_LEVEL
    #       are not set
    peer:       info

    # The overall default values mentioned above can be overridden for the
    # specific components listed in the override section below.

    # Override levels for various peer modules. These levels will be
    # applied once the peer has completely started. They are applied at this
    # time in order to be sure every logger has been registered with the
    # logging package.
    # Note: the modules listed below are the only acceptable modules at this
    #       time.
    cauthdsl:   warning
    gossip:     warning
    ledger:     info
    msp:        warning
    policies:   warning
    grpc:       error

    # Message format for the peer logs
    format: '%{color}%{time:2006-01-02 15:04:05.000 MST} [%{module}] %{shortfunc} -> %{level:.4s} %{id:03x}%{color:reset} %{message}'

或者您可以使用peer cli工具在运行时更新日志记录级别:

$ peer help logging

Log levels: getlevel|setlevel|revertlevels.

Usage:
  peer logging [command]

Available Commands:
  getlevel     Returns the logging level of the requested module logger.
  revertlevels Reverts the logging levels to the levels at the end of peer startup.
  setlevel     Sets the logging level for all modules that match the regular expression.

Global Flags:
      --logging-level string       Default logging level and overrides, see core.yaml for full syntax
      --test.coverprofile string   Done (default "coverage.cov")
  -v, --version                    Display current version of fabric peer server

Use "peer logging [command] --help" for more information about a command.

例如:

peer logging setlevel module_name debug

将更新module_name的日志记录级别进行调试。


1
投票

可以使用docker环境变量覆盖core.yaml对等日志记录属性,例如:

CORE_LOGGING_GOSSIP=debug

要将所有内容置于调试模式,请使用

CORE_LOGGING_LEVEL=debug

您还可以列出选择模块以进入调试模式:

CORE_LOGGING_LEVEL=info:kvledger,statecouchdb,couchdb=debug

请注意,从v1.4开始,有一个新的环境变量在同行和订购者之间是通用的:

FABRIC_LOGGING_SPEC=info:kvledger,statecouchdb,couchdb=debug

0
投票

使用环境变量FABRIC_LOGGING_SPEC仅启用警告。

© www.soinside.com 2019 - 2024. All rights reserved.