<?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="internal-nlog.txt"> <extensions> <add assembly="NLog.Web.AspNetCore"/> </extensions > <variable name="logDirectory" value="${basedir}\logs\"/> <!--define various log targets--> <targets> <!--write logs to file--> <target xsi:type="File" name="allfile" fileName="${logDirectory}\nlog-all-${shortdate}.log" layout="${longdate}|${logger}|${uppercase:${level}}|${message} ${exception}" /> <target xsi:type="Network" name="elastic" keepConnection="false" address ="tcp://ip地址:5000" index="msglog-${shortdate}" 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="elastic" /> </rules> </nlog>
注意:ip地址哪裏的端口爲你配置logstash的input地址: html
ABP日誌經過屬性注入,直接看代碼了 git