You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NLog;
using NLog.Config;
using NLog.Fluent;
namespace NLogStudy.ConsoleApp.Default
{
class Program
{
private static NLog.Logger Logger;
static void Main(string[] args)
{
Demo8();
Console.WriteLine("任意键退出");
Console.ReadKey();
}
static void Demo8()
{
var log = new NLogBox().Logger;
log.Info()
.Message("This is a test fluent message '{0}'.", DateTime.Now.Ticks)
.Property("Test", "InfoWrite")
.Write();
}
static void FluentDemo()
{
var log = new NLogWrap<Program>().Logger;
log.Info()
.Message("This is a test fluent message '{0}'.", DateTime.Now.Ticks)
.Property("Test", "InfoWrite")
.Write();
}
static void Demo2()
{
var log = new NLogWrap<Program>().Logger;
LogEventInfo theEvent = new LogEventInfo(LogLevel.Error, "logconsole", "Pass my custom value");
theEvent.Properties["MyValue"] = "My custom string";
// deprecated
theEvent.Properties["TheAnswer"] = 42;
log.Log(theEvent);
}
static void Demo1()
{
LogManager.Configuration = NLogWrap<Program>.GetConfig();
Logger = LogManager.GetCurrentClassLogger();
Logger.Error("测试错误");
}
}
}