serilog中设置相对路径在window service中不起作用,因为配置了相对路径,实际文件在
C:\Windows\System32
参考如下改为绝对路径后成功。
-----
I had a very similar issue. In my case the problem was with relative paths. I just had to specify absolute path. Now it works like a charm.
WriteTo.RollingFile(AppDomain.CurrentDomain.BaseDirectory + "\\logs\\log-{Date}.log")
Hope it helps!
We had the same issue, this is what we found:
- Serilog configured for rolling logfiles and writing to Seq
- Ddrable logs was enabled.
Symptoms - No log files were being created - No logs written to Seq.
As per @gdoten's comment, our log files were being written to \windows\syswow64 (service was running as localservice).
We believe the permissions on these files may not of allowed the durable spool file to be read causing no logs to be written to Seq.
Fix was to hard code the path of the rollinglogfile and buffer.
loggerFactory.AddFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Log-{Date}.txt"));
Try this one, it worked in my ASP.NET core 2 application runs as windows service