i try to find the answer but they are almost 6 years ago or older.then i see the issue on github. i try to custom a target following github but failed
i get the dll file from nuget package and add to unity as a plugin, then i can use nlog but without any output.
below is my nlog.config
<?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"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="false"
internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log">
<targets>
<target name="UnityLog" type="UnityLog" fileName="c:\log.txt"
layout = "[${longdate}] ${level}(${logger}): ${message} |${all-event-properties}: ${exception:format=tostring}"/>
</targets>
<rules>
<logger name="*" minlevel="Info" writeTo="UnityLog" />
<logger name="*" minlevel="Debug" writeTo="UnityLog" />
</rules>
</nlog>
and the definition of target
using NLog;
using NLog.Layouts;
using NLog.Targets;
using UnityEngine;
[Target("UnityLog")]
public class UnityLog : TargetWithLayout
{
protected override void Write(LogEventInfo logEvent)
{
Name = "UnityLog";
var msg = Layout.Render(logEvent);
Debug.Log(msg);
}
}