Skip to content

清理旧日志文件 - LogCleanupOldFiles

函数简介

清理超过保留数量的旧日志文件。

接口名称

LogCleanupOldFiles

DLL调用

c
int32_t LogCleanupOldFiles(int64_t instance, int64_t loggerHandle, int32_t keepCount);

参数说明

参数名类型说明
instance长整数型OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。
loggerHandle长整数型日志实例句柄(0 表示默认实例)。
keepCount整数型保留文件数量(-1 表示使用配置值)。

示例

SDK 调用

cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
int ret = ola.LogCleanupOldFiles(0, 0);
csharp
using OLAPlug;

var ola = new OLAPlugServer();
int ret = ola.LogCleanupOldFiles(0, 0);
python
from OLAPlugServer import OLAPlugServer

ola = OLAPlugServer()
ret = ola.LogCleanupOldFiles(0, 0)
java
import com.olaplug.OLAPlugServer;

OLAPlugServer ola = new OLAPlugServer();
int ret = ola.LogCleanupOldFiles(0, 0);
cpp
var ola = com("OlaPlug.OlaSoft")
var ret = ola.LogCleanupOldFiles(0, 0)
vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
ret = ola.LogCleanupOldFiles(0, 0)
text
.局部变量 ola, OLAPlug
ola.创建 ()
ret = ola.LogCleanupOldFiles(0, 0)
aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var ret = ola.LogCleanupOldFiles(0, 0);
text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
整数 ret = ola.LogCleanupOldFiles(0, 0)
cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
int32_t ret = ola.LogCleanupOldFiles(0, 0);

原生 DLL 调用

cpp
LogCleanupOldFiles(instance, 0, 0);
csharp
using System.Runtime.InteropServices;
using System.Text;

[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int LogCleanupOldFiles(long ola, int loggerHandle, int keepCount);

LogCleanupOldFiles(instance, 0, 0);
python
from ctypes import CDLL, c_int, c_int64, create_string_buffer

ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
ola.LogCleanupOldFiles(instance, 0, 0)

返回值

返回值说明
1成功。
0失败。

注意事项

项目说明
参数 keepCount 为 -1 时参数 keepCount 为 -1 时,使用 LogSetMaxFiles 设置的值(默认10个)。
清理规则按文件修改时间排序,删除最旧的文件。
当前正在使用的日志文件不会被删除当前正在使用的日志文件不会被删除。
只清理与当前日志实例相关的文件只清理与当前日志实例相关的文件。
清理操作是安全的清理操作是安全的,不会影响正在写入的日志。