Skip to content

基础配置

Henry edited this page Sep 10, 2019 · 1 revision

组件提供两种配置方式,分别是 HttpConfig.json和代码,组件默认会检测程序目录下是否存在配置,如果存则加载配置信息。

配置项描述

{
  "HttpConfig": {
    "BufferPoolMaxMemory": 500,//最大缓存区大小,以MB为单
    "SessionTimeOut": 3600,//会话超时,单位秒;在指定时间内没有请求则关闭连接会话
    "UseIPv6": true,//是否则用IPV6,默认启用
    "UrlIgnoreCase": true,//Url不区分大小写,默认不区分
    "PacketCombined": 0,//合并消息编码,只适用于websocket,0则不开启。
    "LogToConsole": true,//日志是否输出命令行
    "CacheFiles": "html;htm;js;css",//缓存文件类型
    "CacheFileSize": 500,//缓存文件大小,单位KB
    "LogLevel": 8,//日志级别,详细查看对应的类型
    "WebSocketMaxRPS": 100,//会话最大RPS数,只适用于websocket
    "BufferSize": 8096,//缓冲区大小
    "NoGzipFiles": "jpg;jpeg;png;gif;png;ico;zip;rar;bmp",//不开启gzip支持的文件类型,其他文件则开启gzip输出
    "MaxConnections": 2000,//最大连接数
    "WriteLog": true,//是否写日志文件
    "Host": "",//监听地址,不指定则是ipaddress.any
    "Port": 8080,//监听端口
    "MaxBodyLength": 2097152,//最大消息长度
    "OutputStackTrace": false,//异常时是否输出详细代码信息
    "StaticResurceType": "txt;xml;zip;jpg;css;png;htm;woff;svg;gif;woff2;js;html;jpeg;ico;rar",//支持的静态资源 
    "DefaultPage": "product.html;index.html;index.htm"//默认页
  }
}

HTTPS

  • 配置文件
 "SSL": true,
 "CertificateFile": "you.com.pfx",
 "CertificatePassword": "******",
  • 代码
mApiServer.Options.SSL=true;
mApiServer.Options.CertificateFile="you.com.pfx";
mApiServer.Options.CertificatePassword="******";

日志处理

    "WriteLog": true,//日志写文件
    "LogToConsole": true,//日志输出命令行
    "LogLevel": "Warring"//日志级别

或者

mApiServer.Options.WriteLog = true;//日志写文件
mApiServer.Options.LogToConsole = true;//日志输出命令行
mApiServer.Options.LogLevel = BeetleX.EventArgs.LogType.Warring//日志级别

日志级别

    public enum LogType : int
    {
        All = 0,
        Trace = 1,
        Debug = 2,
        Info = 4,
        Warring = 8,
        Error = 16,
        Fatal = 32,
        Off = 64
    }