在Global.asax中
Code
private static readonly ILog log = LogManager.GetLogger(typeof(Global));
Timer logTimer = null;
protected void Application_Start(object sender, EventArgs e)
{
XmlConfigurator.Configure();
logTimer = new Timer(new TimerCallback(Log), null, 0, 1000);
}
protected void Application_End(object sender, EventArgs e)
{
if (logTimer != null)
{
logTimer.Dispose();
}
}
private void Log(object obj)
{
log.Debug("this programe is running!");
}
private static readonly ILog log = LogManager.GetLogger(typeof(Global));
Timer logTimer = null;
protected void Application_Start(object sender, EventArgs e)
{
XmlConfigurator.Configure();
logTimer = new Timer(new TimerCallback(Log), null, 0, 1000);
}
protected void Application_End(object sender, EventArgs e)
{
if (logTimer != null)
{
logTimer.Dispose();
}
}
private void Log(object obj)
{
log.Debug("this programe is running!");
}
转载于:https://www.cnblogs.com/heroking2000/archive/2009/10/23/1588916.html