Closed harishkpv closed 6 years ago
Hi, I downloaded the code and added in Nlog.Web.Aspnetcore in my solution and added it as a reference in my project. After that, I am not getting the above error. I am just guessing, maybe there is a problem with nuget package - Nlog.Web.Aspnetcore. Please check it. Thanks!
NetCoreApp2 should automatically load Nlog.Web.AspNetCore, but NetCoreApp1 needs some help with explicit add assembly. #249 should improve this
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<extensions>
<add assembly="NLog.Web.AspNetCore"/>
</extensions>
See also https://github.com/NLog/NLog.Web/wiki/Getting-started-with-ASP.NET-Core-(csproj---vs2017)
Adding extensions in the config file and it worked.
However, I followed the instructions in the example and currently using AspNetCore.All (2.0.6) - just updated from 2.0.5 with target framework >net Core 2.0
Not sure what I am missing. If you need any information from my side to resolve, please let me know.
Can you create an example project where it is not working? Since the example project here is working:
@snakefoot I ran into this issue as well. Before I added the add assembly line, it was erroring. After I added that line, it was no longer erroring, but these attributes don't get populated in my logs..
<attribute name="requestIp" layout="${aspnet-Request-IP}"/>
<attribute name="controller" layout="${aspnet-MVC-Controller}"/>
<attribute name="action" layout="${aspnet-MVC-Action}"/>
<attribute name="identity" layout="${identity}"/>
I would guess that the problem is it can't find the IHttpContextAccessor -- as I was able to manually populate these properties in a json log class.
@timdoke Have you checked the NLog Internal Logger? https://github.com/NLog/NLog/wiki/Internal-Logging
Another good tool is the debugger.
@snakefoot I had it set to warn and nothing was being populated. I'll change it over to info and see what happens..
Still nothing about these config entries after I switched it to info.. I have a bunch of internal logs that look like this:
2018-04-03 14:31:56.8609 Info Found 41 configuration items 2018-04-03 14:31:56.8729 Info Loading assembly: NLog.Web.AspNetCore 2018-04-03 14:31:56.8729 Info Adding target File Target[jsonFile] 2018-04-03 14:31:56.8729 Info Configured from an XML element in C:\My local path\NLog.config... 2018-04-03 14:31:56.8909 Info Closing old configuration. 2018-04-03 14:31:56.9189 Info Found 41 configuration items
And the main info output is this..
{ "date": "2018-04-03 14:31:57.4259", "level": "INFO", "logger": "MyLoggerName", "aspnetUser": " ", "message": {"ClientId":null,"FunctionName":null,"LoggedInUserId":null,"Message":"Log Test - Status Entry Information Message","ExceptionType":null,"StackTrace":null,"ServerName":"MycomputerName","Url":"0.0.0.1","RouteData":"ServiceStatusController.StatusCheck","JsonInput":null,"CorrelationId":"d2340cd9-8e7a-496f-9d84-255cb556bccd"} }
@timdoke Guess you have to use the debugger then. Anyway please let old issues die. Your issue is completely different than this one (Can see it loads NLog.Web.AspNetCore).
Ok, thanks @snakefoot .. I thought it was highly related as I initially had the same problem -- and then at the end, the original poster said it didn't work and left it at that..
@timdoke If you look at how the issue was closed, then you will see it is referenced by a PullRequest, that fixes the issue. Again please let old issues die.
@timdoke Try upgrading to Nlog.Extensions.Logging 1.0.1
Hi, Getting the error - ArgumentException: LayoutRenderer cannot be found: 'aspnet-request-url'. Is NLog.Web not included?
Using the following nuget packages. The config file is <?xml version="1.0" encoding="utf-8" ?> <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" autoReload="true" throwConfigExceptions="true" internalLogLevel="info" internalLogFile="c:\temp\internal-nlog.txt">