Closed dasjestyr closed 6 years ago
Even leaving the property off entirely could work 👍
Why not simply Environment.MachineName ?? Works on mac/linux in dotnetcore as well.
@drch- good point! I think when this package was written, Environment.MachineName
wasn't present in .NET Core, but it seems like it made it in for the 1.0 (at least according to the docs). We should try to switch the package across 👍
@nblumhardt
Well ... issue already here.
Both COMPUTERNAME
and HOSTNAME
is empty or null on my Linux Ubuntu 16.04.
But System.Environment.MachineName
is present with the right hostname on dotnetcore2
Could be fun to try and do a pull request. :-)
But what should the logic be here? Do we want backward compability here? So just add the third option to try and keep the two others? Could there be some Mono issues with this?
From the property I can see this:
///
@syska thanks for the information. I think just switching to Environment.MachineName
would be the way to go 👍
There is also the quickfix - the correct env variable to look for on Linux is $HOST
instead of $HOSTNAME
. At least for this purpose.
As a workaround you can set
Environment.SetEnvironmentVariable("HOSTNAME", Environment.MachineName);
before calling the enricher.
So when this enricher is run on a linux machine, it outputs "null" in place of the machine name. I think if the machine name isn't able to be obtained, something less obtrusive should be returned such as an empty string.