{"id":19418847,"url":"https://github.com/andrewkeepcoding/serilog-sinks-memorysink","last_synced_at":"2025-04-24T13:35:22.703Z","repository":{"id":234513566,"uuid":"789071737","full_name":"AndrewKeepCoding/serilog-sinks-memorysink","owner":"AndrewKeepCoding","description":null,"archived":false,"fork":false,"pushed_at":"2024-05-15T12:30:43.000Z","size":99,"stargazers_count":9,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-05-16T02:17:04.587Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/AndrewKeepCoding.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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}},"created_at":"2024-04-19T16:49:14.000Z","updated_at":"2024-05-15T12:30:47.000Z","dependencies_parsed_at":"2024-05-16T01:51:06.759Z","dependency_job_id":"c5789185-fe47-4fd6-8166-935496f1949b","html_url":"https://github.com/AndrewKeepCoding/serilog-sinks-memorysink","commit_stats":null,"previous_names":["andrewkeepcoding/serilog-sinks-memorysink"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndrewKeepCoding%2Fserilog-sinks-memorysink","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndrewKeepCoding%2Fserilog-sinks-memorysink/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndrewKeepCoding%2Fserilog-sinks-memorysink/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndrewKeepCoding%2Fserilog-sinks-memorysink/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AndrewKeepCoding","download_url":"https://codeload.github.com/AndrewKeepCoding/serilog-sinks-memorysink/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223954716,"owners_count":17231189,"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-11-10T13:15:27.392Z","updated_at":"2024-11-10T13:15:28.032Z","avatar_url":"https://github.com/AndrewKeepCoding.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"﻿# 🧵 Serilog.Sinks.MemorySink\n\nA [Serilog](https://github.com/serilog/serilog) sink that store log events in memory. You can retrieve these logs and render them in your own log viewer.\n\nThe sample app shows how to create a simple log viewer using WinUI 3.\n\n![Log viewer sample screenshot](winui-3-log-viewer-screenshot.png)\n✨**Getting started**\n\nInstall *Serilog.Sinks.MemorySink*:\n\n```powershell\ndotnet add package Serilog.Sinks.MemorySink\n```\n\nCreate a logger configuration:\n\n```cs\nLog.Logger = new LoggerConfiguration()\n    .WriteTo.MemorySink(out ILogSource\u003cSerilog.Events.LogEvent\u003e logSource)\n    .CreateLogger();\n```\n\nRetrieve logs:\n\n```cs\nvar logs = await logSource.GetLogs(startIndex, requiredCount, cancellationToken);\n```\n\n⚙️**Custom log item, options and exception handling**\n\nTo use a custom log item, you need to provide a log event converter:\n\n```cs\npublic record LogItem(DateTimeOffset Timestamp, LogEventLevel Level, string Message);\n```\n\n```cs\nLog.Logger = new LoggerConfiguration()\n    .WriteTo.MemorySink(\n        out ILogSource\u003cLogItem\u003e logSource,\n        options =\u003e\n        {\n            options.LogEventConverter = logEvent =\u003e\n            {\n                return new LogItem(logEvent.Timestamp, logEvent.Level, logEvent.MessageTemplate.Text);\n            };\n            options.MaxLogsCount = 100_000;\n            options.OnException = ex =\u003e\n            {\n                // Handle sink processing exception.\n            };\n        })\n        .CreateLogger();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrewkeepcoding%2Fserilog-sinks-memorysink","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrewkeepcoding%2Fserilog-sinks-memorysink","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrewkeepcoding%2Fserilog-sinks-memorysink/lists"}