Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running it as a Windows Service #88

Open
robcube opened this issue Jul 9, 2020 · 1 comment
Open

Running it as a Windows Service #88

robcube opened this issue Jul 9, 2020 · 1 comment
Assignees

Comments

@robcube
Copy link

robcube commented Jul 9, 2020

If you run this library in a .NET Core 3.1 Console app using Microsoft.Extensions.Hosting.WindowsService, the logs get written to C:\WINDOWS\SYSTEM32 (which is the Environment.CurrentDirectory). The logs are not written relative to the exe. I had to hard-code the path in the log4net.config file. Is there a way to override this somewhere? Thanks!

@huorswords huorswords self-assigned this Nov 13, 2020
@houbi56
Copy link

houbi56 commented May 19, 2021

Change the current directory before buildig host / configuring logging:

var pathToExe = Process.GetCurrentProcess().MainModule.FileName;
Directory.SetCurrentDirectory(Path.GetDirectoryName(pathToExe));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants