У меня есть класс Serilog:
`
Код: Выделить всё
public class SerilogClass
{
public static readonly ILogger _log;
static SerilogClass()
{
string logsFolder = ConfigurationManager.AppSettings["logsFolder"];
string environment = ConfigurationManager.AppSettings["environment"];
_log = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.File(logsFolder + "//" + DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss") + ".log", outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:Ij}{NewLine}{Exception}")
.CreateLogger();
}
}
Код: Выделить всё
public class MyClass
{
private readonly ILogger _log = SerilogClass._log;
public void GetData()
{
_log.information("run GetData, **here I want to print by default the class path and the line number**")
}
}
Буду рад советам. Спасибо.
Подробнее здесь: https://stackoverflow.com/questions/774 ... in-c-sharp