• log4net.Config


    startup.cs 里修改静态文件的地址:

    app.UseStaticFiles(new StaticFileOptions()
    {
    FileProvider =new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(),@"wwwroot"));
    };

    log4net

    1.添加引用
    2.startup.cs configure 添加
    public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
    {
    loggerFactory.AddLog4Net();
    }
    3. controller 添加
    private readonly ILoggerFactory _loggerFactory;
    public FirstController(ILoggerFactory loggerFactory)
    {
    this._loggerFactory = loggerFactory;
    }

    this._loggerFactory.CreateLogger<FirstController>().LogWarning("This is FirstController-Index 1");

    log4net.Config:

    <?xml version="1.0" encoding="utf-8"?>
    <log4net>
    <!-- Define some output appenders -->
    <appender name="rollingAppender" type="log4net.Appender.RollingFileAppender">
    <file value="loglog.txt" />
    <!--追加日志内容-->
    <appendToFile value="true" />

    <!--防止多线程时不能写Log,官方说线程非安全-->
    <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />

    <!--可以为:Once|Size|Date|Composite-->
    <!--Composite为Size和Date的组合-->
    <rollingStyle value="Composite" />

    <!--当备份文件时,为文件名加的后缀-->
    <datePattern value="yyyyMMdd.TXT" />

    <!--日志最大个数,都是最新的-->
    <!--rollingStyle节点为Size时,只能有value个日志-->
    <!--rollingStyle节点为Composite时,每天有value个日志-->
    <maxSizeRollBackups value="20" />

    <!--可用的单位:KB|MB|GB-->
    <maximumFileSize value="3MB" />

    <!--置为true,当前最新日志文件名永远为file节中的名字-->
    <staticLogFileName value="true" />

    <!--输出级别在INFO和ERROR之间的日志-->
    <filter type="log4net.Filter.LevelRangeFilter">
    <param name="LevelMin" value="ALL" />
    <param name="LevelMax" value="FATAL" />
    </filter>
    <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%date [%thread] %-5level %logger - %message%newline"/>
    </layout>
    </appender>
    <root>
    <priority value="ALL"/>
    <level value="ALL"/>
    <appender-ref ref="rollingAppender" />
    </root>
    </log4net>

  • 相关阅读:
    YOLOV2相对于YOLOV1的改进
    在训练过程中loss出现NaN的原因以及可以采取的方法
    出现梯度消失和梯度爆炸的原因及解决方案
    Batch Normalization 原理
    几种激活函数的对比(二)
    几种激活函数对比(一)
    Leetcode 830. Positions of Large Groups
    Leetcode 985. Sum of Even Numbers After Queries
    python中的赋值与拷贝(浅拷贝与深拷贝)
    Leetcode 665. Non-decreasing Array
  • 原文地址:https://www.cnblogs.com/csj007523/p/14401104.html
Copyright © 2020-2023  润新知