日志信息

日志

1 日志输出配置

功夫宗师交易系统日志输出级别的是可配置的,修改日志输出配置文件设置方式如下。

日志中的具体内容,第一项 “-” 配置为默认配置,其中 log_level 为日志生成级别,日志级别由低到高依次为 DEBUG<INFO<ERROR<FATAL,在该设置的级别以上的日志才会生成。其中 flush_on_level 为日志保存到本地的触发级别,当出现该级别以上的日志时内存中的日志缓存会写到本地文件中。用户可根据自己的需求,定义不同模块的日志输出方式。

$ vi /opt/kungfu/longfist/etc/log/default.json
{
    "folder": "/shared/kungfu/log/",
    "strategy_folder": "/shared/kungfu/log/strategy/",
    "loggers":
    {
        "-":
        {
            "log_level": "INFO",
            "flush_on_level": "ERROR",
            "max_files": 5,
            "max_file_size_MB": 20,
            "pattern": "[%C-%m-%d %T.%e] [%l] [%n] %v",
            "print_level": "DEBUG",
            "print_flag": true,
            "enable_fast_mode": true,
            "queue_size": 8192,
            "file_name": "default.log"
        },
        "engine":
        {
            "-":
            {
                "file_name" : "engine.log"
            },
            "page":
            {
                "-":
                {
                    "file_name": "engine_page.log"
                }
            },
            "trade":
            {
                "-":
                {
                    "file_name": "engine_trade.log"
                },
                "ctp":
                {
                    "file_name": "engine_trade_ctp.log"
                },
                "femas":
                {
                    "file_name": "engine_trade_femas.log"
                }
            },
            "query":
            {
                "-":
                {
                    "file_name": "engine_query.log"
                }
            },
            "md":
            {
                "-":
                {
                    "file_name": "engine_md.log"
                },
                "ctp":
                {
                    "file_name": "engine_md_ctp.log"
                },
                "femas":
                {
                    "file_name": "engine_md_femas.log"
                }
            }
        },
        "strategy":
        {
            "-":
            {
                "file_name": "strategy.log"
            }
        }
    }
}

2 日志目录

系统日志存放在 /shared/kungfu/log 目录下。

日志文件 日志内容 功能
engine_page.log 内存数据库日志 记录内存数据库及其他功能使用内存数据库的情况
engine_md.log 行情服务项日志 记录行情服务启动和运行情况
engine_trade.log 交易服务项日志 记录交易服务启动和执行情况
strategy/xxx.log 策略运行日志 记录策略的运行情况
wingchun/xxx.log 行情和交易服务的分接口详细日志 分接口记录了行情和交易服务的详细日志

3 日志内容

engine_md.log

行情综合日志,kungfu系统接入的所有行情接口的日志均会输出在该文件中,包括行情登录,行情订阅,订阅返回,行情连接中断,行情登出等日志,如下示例为ctp登录的过程日志。

[18-01-19 13:34:33.978] [INFO ] [engine.md.ctp] IEngine::init BrokerId->"***"
[18-01-19 13:34:33.978] [INFO ] [engine.md.ctp] IEngine::init FrontUri->"tcp://*****"
[18-01-19 13:34:33.978] [INFO ] [engine.md.ctp] IEngine::init Password->"***"
[18-01-19 13:34:33.978] [INFO ] [engine.md.ctp] IEngine::init UserId->"***"
[18-01-19 13:34:34.009] [INFO ] [engine.md.ctp] [OnFrontConnected]
[18-01-19 13:34:34.047] [INFO ] [engine.md.ctp] [OnRspUserLogin] (Bid) (Uid) (SName)

engine_trade.log

交易综合日志,kungfu系统接入的交易接口产生的日志均会输出在该文件中,内容包括交易登录,策略连接,下单回报,成交回报,交易登出等日志,如下示例为oes交易接口登录和登出过程

[18-01-18 07:47:11.747] [INFO ] [engine.trade.oes] IEngine::init FeeSetup->{"future":{"ctr_multi":200,"fee_multi":[2.3e-05,0.00069,2.3e-05],"min_fee":0,"type":"amount"},"future_exotic":{"rb":{"ctr_multi":10,"fee_multi":0.0001,"min_fee":0,"type":"amount"}},"stock":{"fee_multi":0.0003,"min_fee":0,"type":"amount"}}
[18-01-18 07:47:11.747] [INFO ] [engine.trade.oes] IEngine::init OrdUri->"tcp:*****"
[18-01-18 07:47:11.747] [INFO ] [engine.trade.oes] IEngine::init QryUri->"tcp:*****"
[18-01-18 07:47:11.747] [INFO ] [engine.trade.oes] IEngine::init RptUri->"tcp:*****"
[18-01-18 07:47:11.747] [INFO ] [engine.trade.oes] IEngine::init accounts->[{"clients":["BlDemo_0"],"info":{"Password":"****","UserId":"****"},"is_default":true}]
[18-01-18 07:47:11.747] [INFO ] [engine.trade.oes] [account] number: 1
[18-01-18 07:47:11.747] [INFO ] [engine.trade.oes] [client] (name)BlDemo_0 (account)
[18-01-18 07:47:11.920] [INFO ] [engine.trade.oes] Login Success! (localId)1
[18-01-18 07:51:30.169] [INFO ] [engine.trade.oes] [IEngine] signal received: 15
[18-01-18 07:51:32.172] [INFO ] [engine.trade.oes] logout succeed!

engine_page.log

内存数据库日志,内存数据库运行过程中产生的日志输出在该文件中,内容包括行情、交易和策略连接数据库和退出数据库。示例展示了 名为 shared_demo 的策略连接数据库的过程信息

[18-01-19 15:06:13.990] [INFO ] [engine.page] [InPage] (folder)/shared/kungfu/journal/strategy (jname)shared_demo (pNum)1 (lpNum)0 (writer?)0
[18-01-19 15:06:43.255] [INFO ] [engine.page] [Demand] (idx)45

wingchun/md_**_out.log

某行情接口日志,包括行情登录,行情订阅,订阅返回,行情连接中断,行情登出等日志,如下示例为ctp登录的过程日志。

wingchun/md_**_err.log

某行情接口错误日志,在行情连接的过程中出现错误导致线程退出时产生的日志输出在该文件中。

wingchun/td_**_out.log

某交易接口日志,包括交易接口登录,行情订阅,订阅返回,行情连接中断,行情登出等日志,如下示例为ctp登录的过程日志。

wingchun/td_**_err.log

某交易接口错误日志,在交易接口连接的过程中出现错误导致线程退出时产生的日志输出在该文件中。

strategy/**.log

策略日志,策略运行过程中产生的日志输出在该文件中。

strategy/**-out.log

策略日志,策略运行过程中产生的日志输出在该文件中。

strategy/**-err.log

策略日志,策略运行过程中出现错误导致线程退出时产生的日志输出在该文件中。