У меня возникли некоторые проблемы с NLog, проектом .NET Core 2.2 AspNet Api и отладкой контейнера Docker в Visual Studio 2017.
Я следовал руководству по установке на сайте NLog Github, добавилКод для метода Program Main, созданный файл nlog.config:
var logger = NLog.Web.NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger();
Debug.Write(logger);
try
{
logger.Debug("init main");
CreateWebHostBuilder(args).Build().Run();
}
catch (Exception ex)
{
//NLog: catch setup errors
logger.Error(ex, "Stopped program because of exception");
throw;
}
finally
{
// Ensure to flush and stop internal timers/threads before application-exit (Avoid segmentation fault on Linux)
NLog.LogManager.Shutdown();
}
Приложение работает невероятно медленно, настройка регистратора занимает много времени.Но в конечном итоге он получает файл конфигурации.
Если я следую выводу, пока он это делает, я получаю непрерывный список сообщений об ошибках следующим образом:
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.2.5/System.Private.CoreLib.dll'. Cannot find or open the PDB file.
Loaded '/app/bin/Debug/netcoreapp2.2/SharpGaming.Api.Gateway.Ui.dll'. Symbols loaded.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.2.5/System.Runtime.dll'. Module was built without symbols.
Loaded '/root/.nuget/fallbackpackages2/nlog/4.6.5/lib/netstandard2.0/NLog.dll'. Cannot find or open the PDB file.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.2.5/netstandard.dll'. Module was built without symbols.
Loaded '/root/.nuget/fallbackpackages2/nlog.web.aspnetcore/4.8.3/lib/netstandard2.0/NLog.Web.AspNetCore.dll'. Cannot find or open the PDB file.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.2.5/System.Diagnostics.Debug.dll'. Module was built without symbols.
Loaded '/usr/share/dotnet/shared/Microsoft.AspNetCore.App/2.2.5/Microsoft.AspNetCore.Hosting.Abstractions.dll'. Cannot find or open the PDB file.
Loaded '/usr/share/dotnet/shared/Microsoft.AspNetCore.App/2.2.5/Microsoft.AspNetCore.Hosting.dll'. Cannot find or open the PDB file.
Step into: Stepping over property 'NLog.Config.ConfigurationItemFactory.get_Default'. To step into properties or operators, go to Tools->Options->Debugging and uncheck 'Step over properties and operators (Managed only)'.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.2.5/System.Runtime.Extensions.dll'. Module was built without symbols.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.2.5/System.Collections.dll'. Module was built without symbols.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.2.5/System.ComponentModel.dll'. Cannot find or open the PDB file.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.2.5/System.Diagnostics.TraceSource.dll'. Cannot find or open the PDB file.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.2.5/System.Net.Primitives.dll'. Cannot find or open the PDB file.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.2.5/System.Data.Common.dll'. Cannot find or open the PDB file.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.2.5/System.Net.Mail.dll'. Cannot find or open the PDB file.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.2.5/System.Threading.ThreadPool.dll'. Module was built without symbols.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.2.5/System.IO.FileSystem.Watcher.dll'. Cannot find or open the PDB file.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.2.5/System.Net.Sockets.dll'. Cannot find or open the PDB file.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.2.5/System.ComponentModel.TypeConverter.dll'. Module was built without symbols.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.2.5/System.Threading.Tasks.dll'. Module was built without symbols.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.2.5/System.Linq.Expressions.dll'. Cannot find or open the PDB file.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.2.5/System.Linq.dll'. Cannot find or open the PDB file.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.2.5/System.Diagnostics.Tools.dll'. Module was built without symbols.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.2.5/System.Private.Uri.dll'. Cannot find or open the PDB file.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.2.5/System.IO.FileSystem.dll'. Module was built without symbols.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.2.5/System.Memory.dll'. Module was built without symbols.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.2.5/System.Buffers.dll'. Module was built without symbols.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.2.5/System.Threading.dll'. Module was built without symbols.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.2.5/System.Runtime.InteropServices.dll'. Module was built without symbols.
Loaded '/root/.nuget/fallbackpackages2/nlog.extensions.logging/1.5.1/lib/netstandard2.0/NLog.Extensions.Logging.dll'. Cannot find or open the PDB file.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.2.5/System.Xml.ReaderWriter.dll'. Module was built without symbols.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.2.5/System.Private.Xml.dll'. Cannot find or open the PDB file.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.2.5/System.Threading.Thread.dll'. Module was built without symbols.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.2.5/System.Security.Cryptography.Algorithms.dll'. Cannot find or open the PDB file.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.2.5/System.Text.Encoding.Extensions.dll'. Module was built without symbols.
Exception thrown: 'System.IO.IOException' in System.Private.CoreLib.dll
Exception thrown: 'System.IO.IOException' in System.Private.CoreLib.dll
Exception thrown: 'System.IO.IOException' in System.Private.CoreLib.dll
Exception thrown: 'System.IO.IOException' in System.Private.CoreLib.dll
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.2.5/System.Collections.Specialized.dll'. Cannot find or open the PDB file.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.2.5/System.Drawing.Primitives.dll'. Cannot find or open the PDB file.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.2.5/System.Threading.Timer.dll'. Module was built without symbols.
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.2.5/System.ComponentModel.Primitives.dll'. Cannot find or open the PDB file.
Exception thrown: 'System.IO.IOException' in System.Private.CoreLib.dll
Exception thrown: 'System.IO.IOException' in System.Private.CoreLib.dll
Exception thrown: 'System.IO.IOException' in System.Private.CoreLib.dll
Exception thrown: 'System.IO.IOException' in System.Private.CoreLib.dll
Exception thrown: 'System.IO.IOException' in System.Private.CoreLib.dll
Exception thrown: 'System.IO.IOException' in System.Private.CoreLib.dll
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.2.5/System.Collections.Concurrent.dll'. Cannot find or open the PDB file.
Exception thrown: 'System.IO.IOException' in System.Private.CoreLib.dll
Exception thrown: 'System.IO.IOException' in System.Private.CoreLib.dll
Exception thrown: 'System.IO.IOException' in System.Private.CoreLib.dll
Exception thrown: 'System.IO.IOException' in System.Private.CoreLib.dll
Exception thrown: 'System.IO.IOException' in System.Private.CoreLib.dll
Exception thrown: 'System.IO.IOException' in System.Private.CoreLib.dll
Exception thrown: 'System.IO.IOException' in System.Private.CoreLib.dll
Exception thrown: 'System.IO.IOException' in System.Private.CoreLib.dll
Exception thrown: 'System.IO.IOException' in System.Private.CoreLib.dll
Exception thrown: 'System.IO.IOException' in System.Private.CoreLib.dll
Loaded '/usr/share/dotnet/shared/Microsoft.AspNetCore.App/2.2.5/Microsoft.AspNetCore.Http.Abstractions.dll'. Cannot find or open the PDB file.
Exception thrown: 'System.IO.IOException' in System.Private.CoreLib.dll
Exception thrown: 'System.IO.IOException' in System.Private.CoreLib.dll
Это продолжается в течение несколькихбольше исключений
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.2.5/System.Console.dll'. Cannot find or open the PDB file.
Exception thrown: 'System.IO.IOException' in System.Private.CoreLib.dll
Loaded '/usr/share/dotnet/shared/Microsoft.NETCore.App/2.2.5/System.Diagnostics.StackTrace.dll'. Module was built without symbols.
Exception thrown: 'System.IO.IOException' in System.Private.CoreLib.dll
Exception thrown: 'System.IO.IOException' in System.Private.CoreLib.dll
... и еще несколько.Вот и все, что настраивает регистратор.
Он продолжает делать это после загрузки регистратора.
Я подумал, что, возможно, он работал в Debug, но DockerFile создал пакет Release.Поэтому я попытался изменить это так, чтобы он выполнялся либо как Release, либо как Debug, но все равно делает то же самое.
Развернутый код в экземпляре Docker не включает файлы PDB, чего я и ожидал.
Это почти как DLL-библиотека NLog пытается работать в Debug, когда она должна быть запущена в Release?
Если я удаляю установочный код для NLog, все работает нормально.Я не получаю ошибок, и приложение работает гладко и быстро в контейнере Docker.
Я использую Windows для Docker и создаю Linux Dockers.
Может кто-нибудь помочь, пожалуйста?