{"id":42538915,"url":"https://github.com/intentor/anlog","last_synced_at":"2026-01-28T17:40:14.365Z","repository":{"id":91059560,"uuid":"127079638","full_name":"intentor/anlog","owner":"intentor","description":"A fast and lightweight key/value pair logger for .NET Core projects","archived":false,"fork":false,"pushed_at":"2019-11-18T00:01:12.000Z","size":194,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-11-27T13:57:29.513Z","etag":null,"topics":["dotnet"],"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/intentor.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}},"created_at":"2018-03-28T03:39:39.000Z","updated_at":"2020-05-21T17:55:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"a9b98728-e026-49c9-861b-4d6c0d5f647e","html_url":"https://github.com/intentor/anlog","commit_stats":null,"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"purl":"pkg:github/intentor/anlog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intentor%2Fanlog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intentor%2Fanlog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intentor%2Fanlog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intentor%2Fanlog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/intentor","download_url":"https://codeload.github.com/intentor/anlog/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intentor%2Fanlog/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28847991,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T15:15:36.453Z","status":"ssl_error","status_checked_at":"2026-01-28T15:15:13.020Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["dotnet"],"created_at":"2026-01-28T17:40:13.644Z","updated_at":"2026-01-28T17:40:14.357Z","avatar_url":"https://github.com/intentor.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ![Anlog](https://user-images.githubusercontent.com/5340818/38121535-4b734df8-33a6-11e8-98aa-e9b8d7234de0.png)\n\n**(Yet) Another .NET Logger**\n\nCurrently the project is **DISCONTINUED**. However, feel free to fork it and continue its development!\n\n[![NuGet Version](http://img.shields.io/nuget/v/Anlog.svg?style=flat)](https://www.nuget.org/packages/Anlog/)\n\nFast and lightweight key/value pair logger for .NET Core projects.\n\n## Contents\n\n1. [Features](#features)\n1. [Quick start](#quick-start)\n1. [Why Anlog?](#why-anlog)\n1. [Sinks](#sinks)\n1. [Formatters](#formatters)\n1. [Minimum log level](#minimum-log-level)\n1. [Object logging](#object-logging)\n1. [License](#license)\n\n## Features\n\n* Key/value pair approach ensures a standardization on logs.\n* Writes to file or memory. \n* Easy to use through a static `Log` object.\n* Fast when formatting and writing.\n\n## Quick start\n\nInstall *Anlog* from the NuGet Gallery:\n\n```\nInstall-Package Anlog\n```\n\nCreate a console application and configure the logger:\n\n```cs\nusing Anlog;\nusing Anlog.Factories;\nusing Anlog.Sinks.Console;\n\nnamespace QuickStart\n{\n    class Program\n    {\n        static void Main(string[] args)\n        {\n            // Creates the logger.\n            Log.Logger = new LoggerFactory()\n                .MinimumLevel.Debug() // Minimum log level to write. In this case, Debug.\n                .WriteTo.Console() // Write to the console.\n                .CreateLogger();\n            \n            // Writes the log to console.\n            Log.Append(\"key\", \"value\").Info();\n            \n            // If possible, when the application ends, dispose the logger to ensure all logs are written.\n            Log.Dispose();\n        }\n    }\n}\n```\n\nLog produced: `2018-03-29 22:22:07.656 [INF] Program.Main:17 key=value`\n\n## Why Anlog?\n\nKeeping logs standardized for an entire application is no easy task. The idea of **Anlog** is to help make logs follow a default convention by using key/value pairs and default formats for different kinds of values.\n\nKey/value pairs also offer an easy and compact way to analyze system logs, making it easier to read, find and standardize.\n\n### History\n\n**Anlog** started as an extension of the great (and widely used) [Serilog](https://serilog.net/) (that’s why it bears some resemblance!). However, due to difficulties of actually implementing it as planned, the project deviated from its original intention and began growing as a full-fledged component.\n\n## Sinks\n\nSinks are objects that write the log to some output, like a file or memory.\n\n### Console\n\nWrites the log to the console.\n\n```cs\nLog.Logger = new LoggerFactory()\n    .WriteTo.Console()\n    .CreateLogger();\n```\n\n#### Settings\n\n- *async*: True if write to the console should be asynchronous, otherwise false. Provides fast writing to console, however due to run in a separated thread, the last log(s) in case of a crash may not be written. The default is false.\n- *theme: Output color theme. The default is none.\n- *minimumLevel*: Minimum log level. The default is the logger minimum level.\n- *formatter*: Log formatter to be used. The default is `CompactKeyValueFormatter`.\n\n### Rolling File\n\nWrites the output to files by period and max file size. Each time a period or a max file size is reached, a new file is created.\n\n```cs\nLog.Logger = new LoggerFactory()\n    .WriteTo.RollingFile()\n    .CreateLogger();\n```\n\n#### Periods\n\nPeriods are defined by constants in the class `Anlog.Sinks.RollingFile.RollingFilePeriod`.\n\n- *Day*: Generates a new file each day. File name format: `log-yyyyMMdd-{fileNumber}.txt`.\n- *Hour*: Generates a new file each hour. File name format: `log-yyyyMMddHH-{fileNumber}.txt`.\n\n\\* `fileNumber` default value is `1` and raises automatically creating a new log file every time log reaches the maximum size value configured.  \n\n#### Settings\n\n- *logFileFolder*: Log files folder path. The default is the application running folder.\n- *period*: Period for rolling the files. The default is `RollingFilePeriod.Day`.\n- *async*: True if write to the console should be asynchronous, otherwise false. Provides fast writing to console, however due to run in a separated thread, the last log(s) in case of a crash may not be written. The default is false.\n- *maxFileSize*: Max file size in bytes. The default is 100mb (104,857,600 bytes).\n- *fileExpiryPeriod*: File expiry period in days. The default is 0 (never).\n- *encoding*: File encoding. The default is UTF8.\n- *bufferSize*: Buffer size to be used. The default is 4096.\n- *minimumLevel*: Minimum log level. The default is the logger minimum level.\n- *formatter*: Log formatter to be used. The default is `CompactKeyValueFormatter`.\n\n### Single File\n\nWrites the log to a single file with unlimited size.\n\n```cs\nLog.Logger = new LoggerFactory()\n    .WriteTo.SingleFile()\n    .CreateLogger();\n```\n\n#### Settings\n\n- *logFilePath*: Log path, including file name and extension. The default is a `log.txt` file in the application running folder.\n- *async*: True if write to the console should be asynchronous, otherwise false. Provides fast writing to console, however due to run in a separated thread, the last log(s) in case of a crash may not be written. The default is false.\n- *encoding*: file encoding. The default is UTF8.\n- *bufferSize*: buffer size to be used. The default is 4096.\n- *minimumLevel*: Minimum log level. The default is the logger minimum level.\n- *formatter*: Log formatter to be used. The default is `CompactKeyValueFormatter`.\n\n### In Memory\n\nWrites the log to a memory buffer. \n\nIt's recommended to use only in tests.\n\n```cs\nLog.Logger = new LoggerFactory()\n    .WriteTo.InMemory()\n    .CreateLogger();\n```\n\nTo get the written logs, use `Log.GetSink()`:\n\n```cs\nvar logs = Log.GetSink\u003cInMemorySink\u003e()?.GetLogs();\n```\n\n### xUnit\n\nAllows writing of logs to the xUnit test console using *Anlog*.\n\nPlease refer to the [project repository](https://github.com/intentor/anlog-sinks-xunit).\n\n#### Settings\n\n- *appendNewLine*: Indicates whether a new line should be appended at the end of each log. The default is true.\n- *minimumLevel*: Minimum log level. The default is the logger minimum level.\n- *formatter*: Log formatter to be used. The default is `CompactKeyValueFormatter`.\n\n## Formatters\n\nFormats the key/value entries. All formatters include class, method name and line number of the log call.\n\n### CompactKeyValue\n\nFormats the key/value entries using a compact approach.\n\n`2018-03-29 22:22:07.656 [INF] c=Program.Main:17 key=value`.\n\nThis is the default formatter for all sinks.\n\n#### Formats\n\n- *Strings*: use the given string. E.g.: `key=text`\n- *Numbers*: use `ToString(culture)`. E.g.: `key=24.11`\n- *Dates*: use `ToString(dateTimeFormat)`. E.g.: `date=2018-03-25 23:00:00.000`\n- *Enums*: use `ToString()`. E.g.: `key=Value`\n- *Arrays* and *IEnumerable*: writes the items between `[]` separated by comma. E.g.: `key=[11.1,24.2,69.3,666.4]`\n- *Classes* with fields and/or properties: writes the fields/properties as key/value pairs between `{}`. E.g.: `{field=24 property=666.11}`\n\n## Minimum log level\n\nIt's possible to set the minimum log level to write to sinks by using the `MinimumLevel` property in the `LoggerFactory`:\n\n```cs\nLog.Logger = new LoggerFactory()\n    .MinimumLevel.Warn()\n    .CreateLogger();\n```\n\nIt's also possible to set the log level by using the `LogLevel` enumeration:\n\n```cs\nLog.Logger = new LoggerFactory()\n    .MinimumLevel.Set(LogLevel.Info)\n    .CreateLogger();\n```\n\nEach sink can override the logger minimum level. Please consult the [Sinks](#sinks) topic for settings of each sink.\n\n### Available log levels\n\n1. *Debug*: internal system logs that are usually intented for developers.\n2. *Info*: general informative logs.\n3. *Warn*: the system may not be behaving as expected.\n4. *Error*: an unexpected issue occured.\n\nThe default minimum log level is *Info*.\n\n## Object logging\n\n### Ignoring fields/properties\n\nIf some field/property in an object needs to be ignored for logging, use the `LogIgnore` atribute:\n\n```cs\npublic class Model\n{\n    [LogIgnore]\n    public int IgnoreProperty { get; set; }\n}\n```\n\n### Caching\n\nAny object with a `DataContract` attribute will be cached for logging during initialization:\n\n```cs\n[DataContract]\npublic class Model\n{\n    ...\n}\n```\n\n## License\n\nLicensed under the [The MIT License (MIT)](http://opensource.org/licenses/MIT). Please see [LICENSE](https://raw.githubusercontent.com/intentor/anlog/master/LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintentor%2Fanlog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fintentor%2Fanlog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintentor%2Fanlog/lists"}