设置单个文件最大大小 - LogSetMaxFileSize
函数简介
设置单个日志文件的最大大小,超过此大小时会自动创建新文件。
接口名称
LogSetMaxFileSize
DLL调用
int32_t LogSetMaxFileSize(int64_t instance, int64_t loggerHandle, int32_t maxFileSizeMb);
参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| instance | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| loggerHandle | 长整数型 | 日志实例句柄(0 表示默认实例) |
| maxFileSizeMb | 整数型 | 单个日志文件最大大小(MB) |
示例
// 设置为50MB
int result = LogSetMaxFileSize(instance, 0, 50);
// 设置为100MB(默认值)
int result = LogSetMaxFileSize(instance, 0, 100);
返回值
1 成功,0 失败。
注意事项
- 默认值:
100MB - 当日志文件达到此大小时,会自动创建新文件(滚动日志)
- 修改后立即生效,如果日志系统已初始化,会自动重新初始化
- 需要配合
LogSetRotationMode的OLA_LOG_ROTATION_SIZE模式使用 - 建议根据磁盘空间和日志量合理设置
