adding nlog to .net core 3.0 application results in
'IServiceCollection' does not contain a definition for 'ConfigureLoggerService' and no accessible extension method 'ConfigureLoggerService' accepting a first argument of type 'IServiceCollection' could be found (are you missing a using directive or an assembly reference?)
for Nuget I have
NLog.Extensions.Logging v1.6.1
NLog.Web.AspNetCore v4.9.0
in startup.cs
public Startup(IConfiguration config)
{
LogManager.LoadConfiguration(String.Concat(Directory.GetCurrentDirectory(), "/nlog.config"));
Configuration = config;
}
public void ConfigureServices(IServiceCollection services)
{
services.AddAuthentication(IISDefaults.AuthenticationScheme);
services.AddMvc();
services.AddTransient<ICwopaAgencyFileRepository, CwopaAgencyFileRepository>();
services.AddTransient<ICurrentUserRepository, CurrentUserRepository>();
services.AddTransient<IUserRepository, UserRepository>();
services.AddTransient<IRevenueReceivedRepository, RevenueReceivedRepository>();
services.AddTransient<ILesseeRepository, LesseeRepository>();
services.AddTransient<ITractLesseeJunctionRepository, TractLesseeJunctionRepository>();
services.AddTransient<IPadRepository, PadRepository>();
services.AddTransient<IWellRepository, WellRepository>();
services.AddTransient<IWellOperarationRepository, WellOperationRepository>();
services.AddTransient<IRoyaltyRepository, RoyaltyRepository>();
services.AddTransient<IRoyaltyAdjustmentCardViewModelRepository, RoyaltyAdjustmentCardViewModelRepository>();
services.AddSingleton<ILoggerManager, LoggerService>();
string conString = Configuration["ConnectionStrings:DefaultConnection"];
services.AddDbContext<DataContext>(options =>
options.UseSqlServer(conString));
services.ConfigureLoggerService();
services.AddMvc(option => option.EnableEndpointRouting = false);
services.AddMemoryCache();
services.AddSession();
}
here is my csproj file
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup Label="Globals">
<SccProjectName>SAK</SccProjectName>
<SccProvider>SAK</SccProvider>
<SccAuxPath>SAK</SccAuxPath>
<SccLocalPath>SAK</SccLocalPath>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.0.0" />
<PackageReference Include="NLog" Version="4.6.8" />
<PackageReference Include="NLog.Extensions.Logging" Version="1.6.1" />
<PackageReference Include="NLog.Web.AspNetCore" Version="4.9.0" />
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="Migrations\" />
</ItemGroup>
</Project>
NLog
package? It is a part ofNLog.Extensions.Logging
, but their GitHub says aboutNLog
package. Please, share yourcsproj
file – Pavel AnikhouskiConfigureLoggerService
is not a method from NLog. Think you are using some broken tutorial. Try look here instead: github.com/NLog/NLog/wiki/Getting-started-with-ASP.NET-Core-3 – Rolf Kristensen