Skip to content

Instantly share code, notes, and snippets.

View litetex's full-sized avatar

litetex

  • BY, Germany
  • 10:21 (UTC +02: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 March 2, 2024 03:12
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.