I'm trying to run a dotnet core WebApi on a MacOs. Running the project with dotnet run works fine, since it runs from source code.
Now i want to pack the Api and run it on other machine, so for that i use the following command
dotnet publish WebApiX.sln -f netcoreapp2.0 -c Release -o ../output -r osx.10.12-x64
which packs the whole application and their dependencies. After this i want to start the web server with dotnet WebApiX.Api.dll but i'm getting the following error:
Unhandled Exception: System.ArgumentNullException: Value cannot be null. Parameter name: pathFormat at Microsoft.Extensions.Logging.FileLoggerExtensions.AddFile(ILoggerFactory loggerFactory, String pathFormat, LogLevel minimumLevel,
IDictionary`2levelOverrides, Boolean isJson,Nullable`1fileSizeLimitBytes,Nullable`1retainedFileCountLimit)
This exception is generated in Configure method presented on Startup class
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
// Configure Midleware
loggerFactory.AddFile(Configuration.GetSection("LogsLocation").Value);
app.UseMiddleware<SerilogMiddleware>();
app.UseMiddleware<ErrorWrappingMiddleware>();
app.UseAuthentication();
app.UseMvc();
}
For testings purposes i tried to remove the line LoggerFactory.. and its strange because the error now is different.
Unhandled Exception: System.InvalidOperationException: Unable to find the required services. Please add all the required services by calling 'IServiceCollection.AddMvc' inside the call to 'ConfigureServices(...)' in the application startup code.
at Microsoft.AspNetCore.Builder.MvcApplicationBuilderExtensions.UseMvc(IApplicationBuilder app, Action`1 configureRoutes)
at WeidertAuth.Api.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) in /Users/mariomarques/Documents/Avnoconn/Projects/WEIDERT/WeidertServices/weidert.auth/WeidertAuth.Api/Startup.cs:line 249
.AddFilemethod - SetappSettingsfile?Configuration.GetSectionwill be looking for a section called "LogsLocation", if that doesn't have a value then that could be where the issue lies - Jamie Taylor