I have found a possible solution. After creating an ASP.NET 5 empty project you can do the following:
1) Open the Startup.cs file and add the following usings:
using Microsoft.Extensions.Logging;
using NLog.Framework.Logging;
Notice that in order to add the second using you have to modify the package.json file by adding the following dependency:
"NLog.Framework.logging": "1.0.0-rc1-final"
2) In the startup.cs file you must modify the signature of the "Configure" method by adding the arguments ihe and ilf. So it will eventually look like this.
Configure(IApplicationBuilder app, IHostingEnvironment ihe, ILoggerFactory ilf)
The arguments ihe and ifg are to be used in this way:
ilf.AddNLog();
ihe.ConfigureNLog("nlog.config");
ILogger logger = ilf.CreateLogger(GetType().Namespace);
logger.LogInformation("i am nlog bye bye");
3) In the project folder, that is not wwwroot but its parent folder, add a file and call it "nlog.config". It can be filled with the following contnent:
<?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"
internalLogLevel="Warn"
internalLogFile="c:\temp\internal.txt">
<!-- define various log targets -->
<targets>
<!-- write logs to file -->
<target xsi:type="File" name="allfile" fileName="c:\temp\nlog-all-${shortdate}.log"
layout="${longdate}|${logger}|${uppercase:${level}}|${message} ${exception}" />
<target xsi:type="File" name="ownFile" fileName="c:\temp\nlog-own-${shortdate}.log"
layout="${longdate}|${logger}|${uppercase:${level}}|${message} ${exception}" />
<target xsi:type="Null" name="blackhole" />
</targets>
<rules>
<!--All logs, including from Microsoft-->
<logger name="*" minlevel="Trace" writeTo="allfile" />
<!--Skip Microsoft logs and so log only own logs-->
<logger name="Microsoft.*" minlevel="Trace" writeTo="blackhole" final="true" />
<logger name="*" minlevel="Trace" writeTo="ownFile" />
</rules>
</nlog>
Now if you run the project and go to C:\temp you will see two files: "nlog-all-.log" and "nlog-own-.log". In the second file you'll see the message "i am nlog bye bye"