Windows-Service 中的 Serilog 未写入日志文件 [英] Serilog in Windows-Service not writing to logfile

查看:151
本文介绍了Windows-Service 中的 Serilog 未写入日志文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 TopShelf 服务中使用 Serilog,登录到控制台和滚动文件.在控制台中运行该服务时,我的消息会写入日志文件,但是当我安装该服务并运行它时,不会发生日志记录.有什么特别需要我配置的吗?文件写入.\logs\log-{date}.txt"下的binaries文件夹.

I am using Serilog within an TopShelf Service, logging to the console and a rolling file. When running the service in a console my messages are written to the logfile, but when I install the service and run it no logging occurs. Is there anything special I need to configure? The file is written to the binaries folder under ".\logs\log-{date}.txt".

最好的问候戈普

推荐答案

我遇到了一个非常相似的问题.就我而言,问题出在相对路径上.我只需要指定绝对路径.现在它就像一个魅力.

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")

希望有帮助!

这篇关于Windows-Service 中的 Serilog 未写入日志文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆