{"id":16481885,"url":"https://github.com/angularsen/portablelog","last_synced_at":"2026-04-16T01:31:16.813Z","repository":{"id":25259507,"uuid":"28684655","full_name":"angularsen/PortableLog","owner":"angularsen","description":"Portable logging interface and adapters to the most common logging implementations","archived":false,"fork":false,"pushed_at":"2015-06-23T19:53:55.000Z","size":1256,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"dev","last_synced_at":"2025-12-20T10:50:35.211Z","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/angularsen.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}},"created_at":"2015-01-01T10:27:33.000Z","updated_at":"2017-02-10T23:41:49.000Z","dependencies_parsed_at":"2022-08-23T04:30:29.397Z","dependency_job_id":null,"html_url":"https://github.com/angularsen/PortableLog","commit_stats":null,"previous_names":["anjdreas/portablelog"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/angularsen/PortableLog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angularsen%2FPortableLog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angularsen%2FPortableLog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angularsen%2FPortableLog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angularsen%2FPortableLog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/angularsen","download_url":"https://codeload.github.com/angularsen/PortableLog/tar.gz/refs/heads/dev","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angularsen%2FPortableLog/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30417685,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-12T06:40:58.731Z","status":"ssl_error","status_checked_at":"2026-03-12T06:40:40.296Z","response_time":114,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":[],"created_at":"2024-10-11T13:08:57.795Z","updated_at":"2026-03-12T07:02:18.401Z","avatar_url":"https://github.com/angularsen.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"PortableLog\n===========\n\n*Version 2 is underway. [Read more](https://github.com/anjdreas/PortableLog/wiki/PortableLog-v2) or get the [pre-release nuget](https://www.nuget.org/packages/PortableLog.Core/2.0.0-alpha2).*\n\n--\n\nPortable logging interface and adapters to the most common logging implementations. Heavily based on [common-logging](https://github.com/net-commons/common-logging), but with a couple of improvements:\n* Move exception parameter first, better readability with ```params object[] args```\n* ILogEx adds InfoEx, WarnEx and similar with [[CallingMemberName]](http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.callermembernameattribute%28v=vs.110%29.aspx) to inject the method name\n* [PortableLog.Core nuget](https://www.nuget.org/packages/PortableLog.Core) with ILog, ILogEx and ILogExFactory to pass in to log producers, such as the portable view models of a cross-platform app\n* [PortableLog.NLog nuget](https://www.nuget.org/packages/PortableLog.NLog) with NLog adapter, to hook up in WPF, WinForms and WinStore. To my knowledge NLog does not yet work with Xamarin for iOS and Android, but adapters for other logging frameworks can easily be added. Pull requests are welcome.\n\nExample\n==\n```csharp\npublic class MyClass\n{\n  private readonly ILogEx _log;\n  \n  public MyClass(ILogExFactory logFactory)\n  {\n    _log = logFactory.GetLogger\u003cMyClass\u003e();\n  }\n  \n  public void MyMethod()\n  {\n    _log.TraceEx(\"On enter.\");\n    \n    _log.Trace(\"MyMethod(): Can always log the old way, or skip logging the method name at all.\");\n    \n    _log.InfoEx(\"Format arguments with 'params' keyword does not work too well \");\n    _log.InfoEx(\"with [CallerMemberName], so you need to \");\n    _log.InfoFormatEx(\"specify the args {0} {1}.\", new object[]{\"like\", \"this\"});\n    \n    _log.InfoEx(\"That means you lose ReSharper intellisense on those args.\");\n    _log.InfoEx(string.Format(\"But you can always log like this if {0} prefer,\", \"you\"));\n    _log.InfoEx(\"or with an extension method for a {0} syntax.\".With(\"shorter\"));\n    \n    try \n    {\n      // ...\n    }\n    catch (Exception e)\n    {\n      _log.ErrorFormat(e, \"Exception arg is now {0} and not confused with format arguments.\", \"first\");\n    }\n    \n    _log.TraceEx(\"On exit.\");\n  }\n}\n```\n\nYields:\n```\n  MyClass.MyMethod: On enter.\n  MyClass.MyMethod(): Can always log the old way, or skip logging the method name at all.\n  MyClass.MyMethod: Format arguments with 'params' keyword does not work too well\n  MyClass.MyMethod: with [CallerMemberName], so you need to \n  MyClass.MyMethod: specify the args like this.\n  MyClass.MyMethod: That means you lose ReSharper intellisense on those args.\n  MyClass.MyMethod: But you can always log like this if you prefer,\n  MyClass.MyMethod: or with an extension method for a shorter syntax.\n  MyClass.MyMethod: On exit.\n```\n\nStringExtensions\n==\nCopy this class to your project to use the With() extension. The StringFormatMethod attributes are just intellisense hints to the ReSharper plugin and can be removed.\n```csharp\ninternal static class StringExtensions\n{\n    [JetBrains.Annotations.StringFormatMethod(\"format\")]\n    public static string With(this string format, IFormatProvider provider, params object[] args)\n    {\n        return string.Format(provider, format, args);\n    }\n\n    [JetBrains.Annotations.StringFormatMethod(\"format\")]\n    public static string With(this string format, params object[] args)\n    {\n        return string.Format(format, args);\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fangularsen%2Fportablelog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fangularsen%2Fportablelog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fangularsen%2Fportablelog/lists"}