log4net

网络来者發表於2024-09-04

建表

CREATE TABLE [dbo].[LogDetails] (
[LogID] int NOT NULL IDENTITY(1,1) ,
[LogDate] datetime NOT NULL ,
[LogThread] nvarchar(100) NOT NULL ,
[LogLevel] nvarchar(200) NOT NULL ,
[LogLogger] nvarchar(500) NOT NULL ,
[LogMessage] nvarchar(3000) NOT NULL ,
[LogActionClick] nvarchar(4000) NULL ,
[UserName] nvarchar(30) NULL ,
[UserIP] varchar(20) NULL
)


2.配置 Log4Net.config

C:\hlm\玻璃配方系統\log4net.config


3.AssemblyInfo.cs中天下下面內容
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "Log4Net.config", Watch = true)]



public class log
{
private static readonly log4net.ILog logtool = log4net.LogManager.GetLogger(typeof(log));
public static void info(LogContent ex)
{
logtool.Info(ex);
}
public static void warn(LogContent ex)
{
logtool.Warn(ex);
}
public static void fatal(LogContent ex)
{
logtool.Fatal(ex);
}
public static void error(LogContent ex)
{
logtool.Error(ex);
}
}