简体   繁体   English

Windows服务的日志文件路径

[英]log file path for windows service

I have a Windows service which does some work and in which I am also trying to write the logs to a file. 我有一个Windows服务,该服务可以执行一些工作,并且我还在其中尝试将日志写入文件中。 Inside my app.Config , I have a section to define the source of the log file: 在我的app.Config ,我有一个部分来定义日志文件的源:

In the Serivce1.cs , I have define the logger as: Serivce1.cs ,我将记录器定义为:

  public partial class Service1 : ServiceBase
    {
        private static TraceSource ServiceLogger = new TraceSource("ServiceTrace");

Inside other methods, I write to the log file by the following code, 在其他方法中,我通过以下代码写入日志文件,

ServiceLogger.TraceEvent(TraceEventType.Information, 1, "{0} : Running", DateTime.Now);

There is not an exception inside the windows event viewer and the service is running with local system (broad previliges) but I am not able to find the log after the installation of this service. Windows事件查看器内部没有例外,该服务正在本地系统上运行(广泛的特权),但是安装该服务后我找不到日志。 Any suggestions? 有什么建议么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM