{"id":31262702,"url":"https://github.com/d3ara1n/ac682.extensions.logging.console","last_synced_at":"2026-05-15T18:06:39.066Z","repository":{"id":117027624,"uuid":"384986231","full_name":"d3ara1n/Ac682.Extensions.Logging.Console","owner":"d3ara1n","description":"a provider for Microsoft.Extensions.Logging which provides a colored console logger.","archived":false,"fork":false,"pushed_at":"2022-07-12T06:15:43.000Z","size":357,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-23T11:56:18.417Z","etag":null,"topics":["console","dotnet","logging"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/d3ara1n.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2021-07-11T15:38:10.000Z","updated_at":"2021-12-24T14:50:39.000Z","dependencies_parsed_at":null,"dependency_job_id":"dd562bfe-e6be-4264-bdcd-1ae38fef5655","html_url":"https://github.com/d3ara1n/Ac682.Extensions.Logging.Console","commit_stats":null,"previous_names":["ac682/ac682.extensions.logging.console"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/d3ara1n/Ac682.Extensions.Logging.Console","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d3ara1n%2FAc682.Extensions.Logging.Console","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d3ara1n%2FAc682.Extensions.Logging.Console/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d3ara1n%2FAc682.Extensions.Logging.Console/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d3ara1n%2FAc682.Extensions.Logging.Console/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/d3ara1n","download_url":"https://codeload.github.com/d3ara1n/Ac682.Extensions.Logging.Console/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d3ara1n%2FAc682.Extensions.Logging.Console/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279005647,"owners_count":26083942,"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","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["console","dotnet","logging"],"created_at":"2025-09-23T11:47:24.166Z","updated_at":"2025-10-11T00:36:59.208Z","avatar_url":"https://github.com/d3ara1n.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ac682.Extensions.Logging.Console\n\n向控制台输出**支持自定义**对象格式的日志条目.\n\n使用[Microsoft.Extensions.Logging门面库](https://www.nuget.org/packages/Microsoft.Extensions.Logging).\n\n## 安装\n\n```powershell\nInstall-Package Ac682.Extensions.Logging.Console\n```\n\n## 注入\n\n```csharp\n// Startup.cs\n\npublic void ConfigureService(IServiceCollection services)\n{\n    services.AddLogging(options =\u003e options\n    {\n        .AddConsole(c =\u003e c\n            .SetMinimalLevel(LogLevel.Information)\n            .AddBuiltinFormatters()\n            .AddFormater\u003cCustomFormatter\u003e())\n    });\n}\n```\n\n## 配置\n\n配置使用 `ConsoleLoggerOptions` 传入.\n\n## 自定义 Formatter\n\n本扩展使用 `IObjectLoggingFormatter` 序列化对象为可在控制台显示的上色文本.\n自己实现该接口然后注册即可自动捕捉特定对象并发挥作用.\n实现过程中缺啥构造啥，没有任何坑.\n\n## 使用 Template\n\n消息模板位于 `ConsoleLoggerOptions`, 可以通过 `ConsoleLoggerOptionsBuilder` 配置.\n形如:\n\n```csharp\nvar template = \"{DateTime:HH:mm:ss} {Level:u4} {Source:s} {Exception|Message}\\n\";\n```\n\n`|` 分隔多个变量，在 `|` 分隔的变量中取存在者优先，顺序靠前者优先，忽略其他。\n\n`:` 分隔变量名和格式化字符串。\n\n| 变量名 | 格式化字符串 | 说明 |\n| --- | --- | --- |\n| DateTime | 标准的 `System.DateTime` 格式 | 事件日期 |\n| Level | \"u\"(默认, 大写), \"l\"(小写). 数字表示截取长度 | 日志等级 |\n| Source | \"s\"(仅类型名), \"l\"(默认, 类型全名) | Logger 的名字(在MSEL中通常为注入者类型全名) |\n| Exception | \"full\"(包含 StackTrace), \"message\"(默认, 仅 Message 属性) | 日志包含的异常对象 |\n| Message | 无 | 消息本身 |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd3ara1n%2Fac682.extensions.logging.console","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fd3ara1n%2Fac682.extensions.logging.console","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd3ara1n%2Fac682.extensions.logging.console/lists"}