我想为.NET Core 2.1解决方案中的日志记录实现AOP。我以前从未使用过它,而我一直在网上寻找,似乎看不到任何有人在Core 2中使用它的示例。有人知道我会怎么做吗?
例如,哪些软件包可用于AOP,并有示例代码可帮助我入门?我使用带有.net核心的内置DI,因此我不必担心该部分。
我正在尝试更改应用程序服务上的访问限制设置,但我似乎找不到 AzureCLI 命令来执行此操作。目前应用程序服务设置为拒绝公共访问,但是我正在寻找代码来将此设置更改为 true,以便我可以添加新的访问限制。我不想通过门户用户界面执行此操作。有谁知道需要传入什么命令或参数来更改此设置,我已经查看了az webapp config access-restriction set,但这没有用于更改值的参数。
我已将 NLog 添加到我的 .NET 核心控制台应用程序中,它适用于文件和数据库目标。但是,当我尝试让它与 eventviewer 一起使用时,它不会记录任何内容。当我为事件查看器目标添加代码时,文件和数据库部分不记录任何内容。当我删除它时,日志记录再次开始工作。
我使用 Powershell 为应用程序添加了一个新的事件查看器源,所以这不是问题。应用程序不会崩溃或报告错误,它运行良好但在包含事件查看器时不会记录任何内容。
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xsi:schemaLocation="NLog NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
internalLogFile="c:\temp\console-example-internal.log"
internalLogLevel="Info" >
<targets>
<target xsi:type="File" name="logfile" fileName="c:\temp\console-example.log"
layout="${date}|${level:uppercase=true}|${message} ${exception}|${logger}|${all-e
vent-properties}" />
<target xsi:type="Console" name="console"
layout="[${longdate}][${machinename}][${level:uppercase=true}] ${message} ${exception}" />
<target xsi:type="EventLog" name="eventlog" source="testlogging" log="Application"
layout="${message}${newline}${exception:format=ToString}" />
<target xsi:type="Database" name="database" >
<connectionString>Server=test; Database=test; User Id=sa; Password=password;</connectionString>
<commandText>
INSERT INTO dbo.Log (Application, Logged, Level, Message, Logger, CallSite, Exception )
VALUES (@Application, @Logged, @Level, @Message, @Logger, @Callsite, @Exception);
</commandText>
<parameter name="@application" layout="TestLoggingApp" />
<parameter name="@logged" layout="${date}" /> …Run Code Online (Sandbox Code Playgroud) asp.net-core ×2
c# ×2
logging ×2
aop ×1
appservice ×1
azure ×1
azure-cli ×1
nlog ×1
powershell ×1