{"id":28960967,"url":"https://github.com/lhx077/ultimate-log-system","last_synced_at":"2025-10-18T20:19:03.484Z","repository":{"id":300392183,"uuid":"1006064794","full_name":"lhx077/Ultimate-Log-System","owner":"lhx077","description":"An ultimate powerful log system designed for .net standard 2.0 ","archived":false,"fork":false,"pushed_at":"2025-06-21T12:22:35.000Z","size":0,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-21T12:36:10.723Z","etag":null,"topics":["dotnet","dotnet-core","dotnet-framework","log","logger","logging","tools","utility","utility-library"],"latest_commit_sha":null,"homepage":"https://www.nuget.org/packages/UltimateLogSystem","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lhx077.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-21T12:13:41.000Z","updated_at":"2025-06-21T12:24:29.000Z","dependencies_parsed_at":"2025-06-21T12:36:12.660Z","dependency_job_id":"a1ac5fa6-9101-473c-9a19-b28ba77a3a4d","html_url":"https://github.com/lhx077/Ultimate-Log-System","commit_stats":null,"previous_names":["lhx077/ultimate-log-system"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/lhx077/Ultimate-Log-System","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lhx077%2FUltimate-Log-System","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lhx077%2FUltimate-Log-System/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lhx077%2FUltimate-Log-System/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lhx077%2FUltimate-Log-System/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lhx077","download_url":"https://codeload.github.com/lhx077/Ultimate-Log-System/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lhx077%2FUltimate-Log-System/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261589822,"owners_count":23181430,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dotnet","dotnet-core","dotnet-framework","log","logger","logging","tools","utility","utility-library"],"created_at":"2025-06-24T02:01:08.705Z","updated_at":"2025-10-18T20:19:03.479Z","avatar_url":"https://github.com/lhx077.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 终极日志系统\n\n这是一个功能全面的.NET日志系统，支持多种日志级别、多种输出格式、多种输出目标，以及丰富的扩展功能。\n\n- [使用指南](使用指南.md)\n- [快速参考](快速参考.md)\n- [API参考](API_Reference.md)\n\n## 主要特性\n\n- **多级别日志**：支持Trace、Debug、Info、Warning、Error、Fatal等预定义级别，也支持自定义日志级别\n- **实时日志记录**：通过后台线程处理，不阻塞主线程\n- **时间戳**：每条日志都附带精确时间戳\n- **滚动文件更新**：支持按大小自动滚动更新日志文件\n- **日期滚动日志**：支持按日期创建新文件，同一天多次启动应用时自动创建不同的日志文件\n- **自定义头信息**：可以为日志添加自定义类别和属性\n- **多格式支持**：支持文本、JSON、XML等多种格式\n- **内置解析器**：支持解析各种格式的日志文件\n- **彩色输出**：控制台输出支持不同颜色\n- **事件响应**：支持根据日志级别或内容触发不同操作\n- **上下文支持**：支持日志上下文，方便跟踪请求\n- **结构化日志**：支持记录结构化数据\n- **性能监控**：内置操作计时功能\n- **导入导出**：支持导入导出各种格式的日志\n\n## 快速开始\n\n### 安装\n\n```bash\ndotnet add package UltimateLogSystem\n```\n\n### 基本用法\n\n```csharp\n// 创建日志配置\nvar config = new LoggerConfiguration()\n    .SetMinimumLevel(LogLevel.Info)\n    .AddConsoleWriter()\n    .AddFileWriter(\"logs/app.log\");\n\n// 创建日志记录器\nvar logger = LoggerFactory.CreateLogger(config);\n\n// 记录日志\nlogger.Info(\"应用程序启动成功\");\nlogger.Warning(\"发现潜在问题\");\nlogger.Error(\"发生错误\", exception: ex);\n\n// 关闭日志系统\nLoggerFactory.CloseAll();\n```\n\n### 高级用法\n\n```csharp\n// 创建更复杂的配置\nvar config = new LoggerConfiguration()\n    .SetMinimumLevel(LogLevel.Trace)\n    .SetDefaultCategory(\"MyApp\")\n    .AddConsoleWriter(new TextFormatter(\"[{timestamp}] [{level}] {message}\"))\n    .AddFileWriter(\"logs/app.log\", maxFileSize: 5 * 1024 * 1024, maxRollingFiles: 10)\n    .AddFileWriter(\"logs/app.json\", new JsonFormatter())\n    .AddEmailNotification(\n        \"smtp.example.com\", 587,\n        \"alerts@example.com\", \"admin@example.com\",\n        \"username\", \"password\",\n        LogLevel.Error);\n\n// 使用上下文属性\nLogContext.SetProperty(\"UserId\", \"12345\");\nlogger.Info(\"用户登录成功\");\n\n// 结构化日志\nlogger.LogStructured(LogLevel.Info, \"用户 {UserName} 执行了 {Action}\", \n    new { UserName = \"张三\", Action = \"登录\" });\n\n// 性能监控\nlogger.Time(() =\u003e {\n    // 执行耗时操作\n}, \"数据库查询\");\n```\n\n## 扩展\n\n### 自定义输出目标\n\n```csharp\npublic class MyCustomWriter : ILogWriter\n{\n    public void Write(LogEntry entry)\n    {\n        // 自定义日志处理逻辑\n    }\n    \n    public void Flush() { }\n    \n    public void Dispose() { }\n}\n\n// 使用自定义输出\nconfig.AddWriter(new MyCustomWriter());\n```\n\n### 自定义格式化器\n\n```csharp\npublic class MyFormatter : ILogFormatter\n{\n    public string Format(LogEntry entry)\n    {\n        // 自定义格式化逻辑\n        return $\"自定义格式: {entry.Message}\";\n    }\n}\n\n// 使用自定义格式化器\nconfig.AddConsoleWriter(new MyFormatter());\n```\n\n## 许可证\n\nApache 2.0 ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flhx077%2Fultimate-log-system","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flhx077%2Fultimate-log-system","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flhx077%2Fultimate-log-system/lists"}