Search code examples
c#serilog

CallerLineNumber from config file in serilog


Is there a way to configure CallerLineNumber from config file in C#? I have gone through https://stackoverflow.com/a/46905798/5035500 and https://gist.github.com/litetex/b88fe0531e5acea82df1189643fb1f79 which are good examples but the configuration is in C# code.


Solution

  • CallerLineNumber is not something Serilog supports out-of-the-box... The examples you mentioned are all custom abstractions on top of Serilog.

    If you want to control this behavior via config, you'll have to write your own custom code to read specific parameters from the config file and set up the Serilog pipeline accordingly.