Skip to content

Instantly share code, notes, and snippets.

View litetex's full-sized avatar

litetex

  • Germany
  • 23:28 (UTC +01:00)
View GitHub Profile
@litetex
litetex / HowToGetAndroidLogs.md
Last active September 15, 2021 20:04
How to get Android logs
@litetex
litetex / Description.md
Last active September 18, 2024 02:25
Serilog (C#): How to get current MethodName, FileName/Path and LineNumber without reflection

Serilog (C#): How to get the current MethodName, FileName/Path and LineNumber without reflection

This is a simple setup for reflectionless logging with serilog using caller information (and a single static class).

See also https://stackoverflow.com/a/46905798

Log.cs

Create your own Log.cs in your Root-Namespace (you can use the class below).

This class is required to detect where the call is coming from; it uses Caller-Information to speed up the program execution, because the attributes are resolved at compile-time.