标签:
Add the following line to the above project‘s AssemblyInfo.cs file (allows a custom log4net config file to be specified, which log4net will "watch" for updates. Quick, but maybe a bit dirty..)
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)]
Add log4net.config file to console project and copy it to the output directory (file properties: "Copy to Output Directory")
Declare the logger as private static member of the classes where you need logging:
private static readonly log4net.ILog Logger =
log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
Log where required:
Logger.Info("Starting console service host");
using log4net on my project within a self-hosted WCF application z
标签:
原文地址:http://www.cnblogs.com/zeroone/p/4447884.html