.net core webapi 添加日志管理看板LogDashboard
添加权限管理:
我们用的是Nlog文件来配置
<?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"throwExceptions="false"internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log"><variable name="myvar" value="myvalue"/><targets><target xsi:type="file" name="File" fileName="${basedir}/logs/${shortdate}.log"layout="${longdate}||${level}||${logger}||${message}||${exception:format=ToString:innerFormat=ToString:maxInnerExceptionLevel=10:separator=\r\n}||end" /></targets><rules><logger name="*" minlevel="Trace" writeTo="file" /></rules>
</nlog>
安装日志Nlog
安装日志看板
配置权限代码:
var user = configuration["logUser"];
var password = configuration["logPassword"];builder.Services.AddLogDashboard(opt =>
{opt.AddAuthorizationFilter(new LogDashboardBasicAuthFilter(user, password));
});
启动:
app.UseLogDashboard();