Aore.Logger.Oracle 1.2.2

dotnet add package Aore.Logger.Oracle --version 1.2.2
                    
NuGet\Install-Package Aore.Logger.Oracle -Version 1.2.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Aore.Logger.Oracle" Version="1.2.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Aore.Logger.Oracle" Version="1.2.2" />
                    
Directory.Packages.props
<PackageReference Include="Aore.Logger.Oracle" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Aore.Logger.Oracle --version 1.2.2
                    
#r "nuget: Aore.Logger.Oracle, 1.2.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Aore.Logger.Oracle@1.2.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Aore.Logger.Oracle&version=1.2.2
                    
Install as a Cake Addin
#tool nuget:?package=Aore.Logger.Oracle&version=1.2.2
                    
Install as a Cake Tool

Aore.Logger.Oracle — Oracle 日志扩展包

Aore.Logger 的 Oracle 数据库日志目标:面向已有 Oracle 资产/DBA 运维体系的企业环境,RAW(16)/CLOB 原生类型。

1. 作用与目的

把日志同步写入 Oracle 数据库表,支持:

  • 自动建表/建索引:构造时自动建表 + 时间戳/级别索引;
  • 企业级类型:RAW(16) Guid 主键、CLOB 大字段、NUMBER 行号;
  • 字段映射:9 个字段列名逐字段可配、可置 null 跳过,支持写入现有表;
  • 保留清理:可选按天保留,后台按 ROWID 分批删除(每批 5000 行),不阻塞写入;
  • 参数化写入:全部值经驱动参数绑定,无 SQL 注入面。

2. 安装与依赖

dotnet add package Aore.Logger.Oracle
  • 依赖驱动按目标框架自动选择:
    • netstandard2.1 / net8.0 → Oracle.ManagedDataAccess.Core 3.21.120(ODP.NET 托管驱动)
    • net462 / net472 / net48 → Oracle.ManagedDataAccess 21.12.0
  • 必须同时引用核心包 Aore.Logger
  • 目标框架:netstandard2.1 / net462 / net472 / net48 / net8.0(注意:没有 netstandard2.0)

3. 快速上手

using Aore.Logger;

Logger.Instance.Configure(new LoggerConfig
{
    EnableFileLog = false,
    EnableDatabaseLog = true,
    DatabaseLogConfig = new DatabaseLogConfig
    {
        DatabaseType = DatabaseType.Oracle,
        ConnectionString = "User Id=loguser;Password=******;Data Source=192.168.1.40:1521/ORCLPDB1",
        TableName = "Logs"
    }
});

Logger.Instance.Info("写入 Oracle 的日志");

连接失败/建表失败在 Configure 时抛出(保留旧目标列表并带内层异常)。

4. 自动创建的表与索引

CREATE TABLE "LOGS" (
    "ID" RAW(16) NOT NULL PRIMARY KEY,            -- Guid 二进制存储
    "TIMESTAMP" TIMESTAMP NOT NULL,               -- 毫秒精度
    "LEVEL" VARCHAR2(50) NOT NULL,
    "MESSAGE" CLOB NOT NULL,
    "EXCEPTION" CLOB,
    "MEMBERNAME" VARCHAR2(500),
    "FILEPATH" VARCHAR2(1000),
    "LINENUMBER" NUMBER,
    "CREATEDGMT" TIMESTAMP NOT NULL               -- UTC 时间(Timestamp 转换)
);
-- 另按已映射列创建 Timestamp 与 Level 两个索引

5. 连接字符串

ODP.NET 格式:

  • EZCONNECT:User Id=;Password=;Data Source=host:port/service
  • TNS 别名:Data Source=ORCLPDB1(驱动从 TNS_ADMIN 查找 tnsnames.ora)

支持 Pooling=true(默认开)、Statement Cache Size 等扩展键。

6. 清理(保留策略)

IsClearingExecuted = true 启用:写入时命中周期窗口派发后台清理,按已映射的时间戳列删除早于 RetentionDays 的行;按 ROWID + ROWNUM 分批(5000 行/批)循环删除——短事务、不依赖 Id 列(自增/IDENTITY 表 IdColumn = null 清理照常)。

7. 写入现有表(字段映射)

DatabaseLogConfig = new DatabaseLogConfig
{
    DatabaseType = DatabaseType.Oracle,
    ConnectionString = "...",
    TableName = "SYS_OPER_LOG",
    IdColumn = null,                      // GENERATED ALWAYS AS IDENTITY 表必须置 null!
    TimestampColumn = "CREATED_AT",
    LevelColumn = "LOG_LEVEL",
    MessageColumn = "CONTENT"
}

8. 本方言注意事项

  1. 标识符统一大写:本包把表名/列名大写后加双引号转义——自建表在数据库中实际为大写名(如 "LOGS"),查询时注意大小写;
  2. 索引名上限 30 字符(Oracle 11.2 及以下限制口径):超长自动截断 + FNV-1a 哈希后缀;
  3. default(DateTime)(0001-01-01)超出 Oracle TIMESTAMP 语义范围,Timestamp 请使用正常业务时间;
  4. 排障可用 new OracleLogTarget(config).TestConnection() 探测连通性;
  5. 驱动为托管实现,无需安装 Oracle 客户端;net462/472/48 使用 .NET Framework 版驱动包,依赖已随包自动引入。
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
.NET Framework net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 is compatible.  net48 is compatible.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.2 0 9/28/2026
1.2.1 37 9/25/2026
1.2.0 64 9/25/2026 1.2.0 is deprecated because it is no longer maintained.

Oracle logging extension for Aore.Logger