C# 将NLog配置为在设置的星期几进行日志记录
我有一个每小时运行一次的服务,它在异常发生时使用NLog发送邮件。那么,我如何将其配置为不在周六和周日登录?我能做到吗 我的目标是:C# 将NLog配置为在设置的星期几进行日志记录,c#,nlog,C#,Nlog,我有一个每小时运行一次的服务,它在异常发生时使用NLog发送邮件。那么,我如何将其配置为不在周六和周日登录?我能做到吗 我的目标是: <target name="m" xsi:type="Mail" html="true" smtpServer="*******" smtpPort="*******" smtpAuthentication="*******" smtpUserName="*******" smtpPassword="*******"
<target name="m"
xsi:type="Mail"
html="true"
smtpServer="*******"
smtpPort="*******"
smtpAuthentication="*******"
smtpUserName="*******"
smtpPassword="*******"
enableSsl="true"
subject="Exception"
from="*******"
to="*******"
layout ="${longdate} ${uppercase:${level}}${newline} ${callsite:className=true:includeSourcePath=true:methodName=true}${newline} ${message}${newline}"
useSystemNetMailSettings="false" />
和规则:
<logger name="*" minlevel="Fatal" writeTo="m" />
可以使用PostFilteringRapper,并使用如下过滤条件:
- 不等于(“${date:format=ddd}”,“Sat”)
- 不等于(“${date:format=ddd}”,“Sun”)
您希望服务运行,但不记录任何内容?为什么?我想要正常的日志,但没有电子邮件(我有两个目标)。我还将其设置为发送5封不同的电子邮件。这意味着,如果应用程序每次崩溃,就会发送300多封电子邮件。在我看来,正确的做法是修复应用程序,使其不会崩溃。@Amy好的,事情是这样的:我的应用程序从第三方API获取数据。有时这些API会返回异常。所以我的应用程序不会崩溃。我只是想知道第三方API是否崩溃。但不是在我的周末。