Hi! Thanks for reporting this feature/bug/question!
Please keep / fill in the relevant info from this template so that we can help you as best as possible.
QUESTIONS are preferred on StackOverflow. You could expect a faster response there (but do include all the info below). Use the tag "nlog" https://stackoverflow.com/questions/ask
For .NET Core users, please check the platform support: https://github.com/NLog/NLog/wiki/platform-support
NLog version: NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 4.7.2.11786. Product version: 4.7.2+024896f64b840a743d3fd89e29c2186681e7795f. GlobalAssemblyCache: False
Platform: .NET Core 3.1 on Linux (CentOS 7)
Current NLog config (xml or C#, if relevant)
I don't recall if I had "throwExceptions" enabled when I saw the error message. I think it was off.
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
throwExceptions="false" internalLogLevel="Info" internalLogToConsole="true" internalLogIncludeTimestamp="true" >
<!-- used for file logging -->
<variable name="logDir" value="/some/path/log" />
<variable name="logFileBaseName" value="logFileName" />
<!-- used for file logging -->
<targets>
<target type="File"
name="file"
encoding="UTF-8"
layout="${date:universalTime=false:format=yyyy-MM-dd HH\:mm\:ss.ffffzzz} ${level:uppercase=true} ${processname:fullName=false} : ${assembly-version} (${hostname}:${local-ip}:${environm\ent-user}) Thread(${threadid}:${threadname}) ${callsite}:${callsite-linenumber} - ${message} ${exception:format=tostring}"
lineEnding="Default"
fileName="${logDir}/${logFileBaseName}.log"
archiveFileName="${logDir}/Archive/${logFileBaseName}.{#}.log.zip"
enableArchiveFileCompression="true"
archiveOldFileOnStartup="false"
maxArchiveFiles="60"
archiveNumbering="Date"
archiveEvery="Day"
archiveDateFormat="yyyyMMdd"
concurrentWrites="true"
/>
</targets>
<rules>
<logger name="*" minlevel="Info" writeTo="file" />
</rules>
</nlog>
I also have a similar target for elastic, but excluded it for brevity
2020-06-10 13:38:50.9425 Warn Failed to lookup NetworkInterface.GetAllNetworkInterfaces() Exception: System.PlatformNotSupportedException: The information requested is unavailable on the current platform.
at System.Net.NetworkInformation.UnixUnicastIPAddressInformation.get_IsDnsEligible()
at NLog.LayoutRenderers.LocalIpAddressLayoutRenderer.CalculateNetworkAddressScore(UnicastIPAddressInformation networkAddress, IPInterfaceProperties ipProperties)
at NLog.LayoutRenderers.LocalIpAddressLayoutRenderer.LookupIpAddress()
2
What is the expected result?
I would want the log message written to the target even if the layout is not supported, a "blank" string should be acceptable when a layout fails
Did you checked the Internal log?
See above
Hi! Thanks for opening your first issue here! Please make sure to follow the issue template - so we could help you better!
The warning you see is written to InternalLogger here:
But NLog should avoid using properties that will always fail on Linux. Created #4011 to fix this.
Btw. ${local-ip} can be very slow. It is recommended to use ${local-ip:cachedSeconds=60}
See also: https://github.com/NLog/NLog/wiki/Local-IP-Address-Layout-Renderer
Closing this issue as resolved by #4011
@johnjaylward You are very welcome to check if this pre-release build resolves the issue:
https://ci.appveyor.com/project/nlog/nlog/builds/33445802/artifacts (Download NLog.4.7.2.11884-PR4011.nupkg and use in local-path-nuget-repository)
Thanks for the quick fix!
Most helpful comment
Closing this issue as resolved by #4011
@johnjaylward You are very welcome to check if this pre-release build resolves the issue:
https://ci.appveyor.com/project/nlog/nlog/builds/33445802/artifacts (Download NLog.4.7.2.11884-PR4011.nupkg and use in local-path-nuget-repository)