{"id":13600486,"url":"https://github.com/serilog-contrib/Serilog.Sinks.DelegatingText","last_synced_at":"2025-04-11T00:31:24.415Z","repository":{"id":41967367,"uuid":"380439075","full_name":"serilog-contrib/Serilog.Sinks.DelegatingText","owner":"serilog-contrib","description":"A Serilog sink to emit formatted log events to a delegate.","archived":false,"fork":false,"pushed_at":"2023-09-04T17:27:40.000Z","size":88,"stargazers_count":3,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-15T23:06:27.449Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/serilog-contrib.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}},"created_at":"2021-06-26T07:10:09.000Z","updated_at":"2024-07-12T00:02:16.000Z","dependencies_parsed_at":"2024-01-14T06:04:53.513Z","dependency_job_id":"26c0ac33-1d3e-4263-b321-ace4238c4bdb","html_url":"https://github.com/serilog-contrib/Serilog.Sinks.DelegatingText","commit_stats":null,"previous_names":["victorvogelpoel/serilog.sinks.delegatingtext"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serilog-contrib%2FSerilog.Sinks.DelegatingText","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serilog-contrib%2FSerilog.Sinks.DelegatingText/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serilog-contrib%2FSerilog.Sinks.DelegatingText/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serilog-contrib%2FSerilog.Sinks.DelegatingText/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/serilog-contrib","download_url":"https://codeload.github.com/serilog-contrib/Serilog.Sinks.DelegatingText/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248322263,"owners_count":21084334,"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":[],"created_at":"2024-08-01T18:00:39.853Z","updated_at":"2025-04-11T00:31:24.017Z","avatar_url":"https://github.com/serilog-contrib.png","language":"C#","funding_links":[],"categories":["Development"],"sub_categories":["NuGET Packages"],"readme":"# Serilog.Sinks.DelegatingText\n\n[![Nuget status](https://img.shields.io/nuget/v/Serilog.Sinks.DelegatingText.svg)](https://www.nuget.org/packages/Serilog.Sinks.DelegatingText)\n\nA Serilog sink wrapper to write formatted log events to a delegate.\n\nTo use the sink, install the **Serilog.Sinks.DelegatingText nupkg** into your solution; see below or browse to the [sample sandbox code in this repository](src/SANDBOX/Program.cs) for pointers how to use it. And here is the nuget.org page for [Serilog.Sinks.DelegatingText](https://www.nuget.org/packages/Serilog.Sinks.DelegatingText/).\n\n*Please note that this library is provided \"as-is\" and with no warranty, explicit or otherwise. You should ensure that the functionality meets your requirements, and thoroughly test them, prior to using in any production scenarios.*\n\n## Use case\n\nThe **Serilog.Sinks.DelegatingText** sink makes it possible buffer formatted log events in your application. For more information about Serilog, see [Serilog.net](https://serilog.net/) and [https://github.com/serilog/serilog](https://github.com/serilog/serilog).\n\n\n```csharp\nprivate readonly StringBuilder  _logEventBuffer = new StringBuilder();\n\nprivate void ConfigureApp()\n{\n    Log.Logger = new LoggerConfiguration()\n        // Using a delegate to buffer log messages\n        .WriteTo.DelegatingTextSink(w =\u003e WriteToBuffer(w), outputTemplate:\"[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}\")\n        .CreateLogger();\n\n    Log.Information(\"Hello from the sandbox\");\n    Log.Warning(\"Sample warning\");\n    Log.Error(\"Sample error\");\n    Log.Error(new Exception(\"A sample exception\"), \"Sample error with exception\");\n\n    // ...\n}\n\nprivate void WriteToBuffer(string formattedLogMessage)\n{\n    _logEventBuffer.AppendLine(formattedLogMessage.TrimEnd(Environment.NewLine.ToCharArray()));\n}\n\nprivate void SomeFunction()\n{\n    // do something with the buffered log events\n    _logEventBuffer.ToString();\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserilog-contrib%2FSerilog.Sinks.DelegatingText","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fserilog-contrib%2FSerilog.Sinks.DelegatingText","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserilog-contrib%2FSerilog.Sinks.DelegatingText/lists"}