首页 > 其他分享 >.net Core Winform 增加NLog

.net Core Winform 增加NLog

时间:2023-07-05 11:26:14浏览次数:43  
标签:Core MainForm NLog net logger Logger Winform

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" >
    <targets async="true" maxarchivefiles="2">
        <target name="log_file" xsi:type="File" 
                fileName="${basedir}/logs/gadget.${date:format=yyyyMMdd}.log"
                layout="[${longdate}|${level}|${message}|${exception}]"/>
        <target  name="log_file2" xsi:type="File"  fileName="${basedir}/logs/gadget.${date:format=yyyyMMdd}.log"
                layout="[----------------------------${newline}${date} ${appdomain}  ${logger} ${level}${newline}${message}${newline}${exception}]"/>
    </targets>
    <rules>
        <logger name="*" minlevel="trace"  writeTo="log_file"></logger>
    </rules>
</nlog>

 

NuGet packages

<PackageReference Include="NLog.Web.AspNetCore" Version="5.3.1" />

调用

Logger Logger { get { return LogManager.Setup().LoadConfigurationFromAppSettings().GetCurrentClassLogger(); } }
logger.Info("MainForm");
logger.Error("MainForm");
logger.Debug("MainForm");
logger.Trace("MainForm");
logger.Warn("MainForm");

 

标签:Core,MainForm,NLog,net,logger,Logger,Winform
From: https://www.cnblogs.com/hofmann/p/17528015.html

相关文章

  • javax.net.ssl.SSLHandshakeException: The server selected protocol version TLS10
    问题:报错:javax.net.ssl.SSLHandshakeException:TheserverselectedprotocolversionTLS10isnotacceptedbyclientpreferences[TLS12]解决方式:1、修改%JAVA_HOME%/jre/lib/security/java.security2、修改内容:jdk.tls.disabledAlgorithms删除TLSv13、删除前: https:......
  • WideNet:让网络更宽而不是更深
    这是新加坡国立大学在2022aaai发布的一篇论文。WideNet是一种参数有效的框架,它的方向是更宽而不是更深。通过混合专家(MoE)代替前馈网络(FFN),使模型沿宽度缩放。使用单独LN用于转换各种语义表示,而不是共享权重。 https://avoid.overfit.cn/post/fd66d50b81fc4e4e83bb3bba42f4......
  • .net Core API 添加 NLog
    nlog.config<?xmlversion="1.0"encoding="utf-8"?><nlogxmlns="http://www.nlog-project.org/schemas/NLog.xsd"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"autoReload="true"......
  • Sentieon | 每周文献-Genetic Disease-第二期
    遗传病系列文章-1标题(英文):AnswerALS,alarge-scaleresourceforsporadicandfamilialALScombiningclinicalandmulti-omicsdatafrominducedpluripotentcelllines标题(中文):AnswerALS,一种用于散发性和家族性ALS的大规模资源,结合了来自诱导多能细胞系的临床和多......
  • Noisy Networks for Exploration
    郑重声明:原文参见标题,如有侵权,请联系作者,将会撤销发布!PublishedasaconferencepaperatICLR2018ABSTRACT 1INTRODUCTION 2BACKGROUND 2.1MARKOVDECISIONPROCESSESANDREINFORCEMENTLEARNING 2.2DEEPREINFORCEMENTLEARNING ......
  • .Net下验证MongoDB 的 Linq 模式联合查询是否可用
    MongoDB.Driver类库提供了Linq查询的支持。然而,在使用Linq进行联合查询时,是否能够正确转换为MongoDB底层的查询语句还有待验证。今天,我将进行实验来验证一下。输出查询语句首先,通过订阅MongoClientSettings的功能,将查询语句输出。varsettings=MongoCli......
  • asp.net core如何获取客户端IP地址
    客户端直接访问服务器直接通过HttpContext.Connection.RemoteIpAddress获取客户端Ip[HttpGet][Route("GetClientIP")]publicasyncTask<IActionResult>GetClientIP(){ varip4=HttpContext.Connection.RemoteIpAddress.MapToIPv4(); returnOk(ip4.ToString());}客......
  • 如何将SSL证书从Kubernetes Secrets导出并复原为证书PEM和密钥文件
    首先,您需要使用kubectl工具从Kubernetes导出Secret到一个yaml文件,这通常使用如下命令:kubectlgetsecretmy-secret-oyaml>my-secret.yaml然后我们可以创建一个简单的bash脚本来处理yaml文件并导出证书:#!/bin/bash#解析yaml文件并得到证书内容certData=......
  • windows下mysql中binlog日志分析和数据恢复
    1.首先查看是否开启了binlogshowvariableslike'%log_bin%'; 我的已经开启了,如果没开启则开启binlog2.查看有哪些binlog文件和正在使用的binlog文件 查看有哪些binlog文件showbinarylogs;或者showmasterlogs; 查看当前正在使用的是哪一个binlog文件show......
  • 【Netty】「萌新入门」(三)ChannelFuture 与 CloseFuture
    前言本篇博文是《从0到1学习Netty》中入门系列的第三篇博文,主要内容是介绍Netty中ChannelFuture与CloseFuture的使用,解决连接问题与关闭问题,往期系列文章请访问博主的Netty专栏,博文中的所有代码全部收集在博主的GitHub仓库中;连接问题与ChannelFuture在Netty中,所有的......