こんにちは私はXML構成を使用せずにlog4netをセットアップしようとしています:
public void InitLogger()
{
//Create exception log file if it haven't been created
var exceptionLogFile = new FileInfo(System.Configuration.ConfigurationManager.AppSettings["ExceptionLogFilePath"]);
if (!exceptionLogFile.Exists)
{
exceptionLogFile.Create();
}
//configure log4net
var smtpAppender = new SmtpAppender
{
SmtpHost = "",
Authentication = SmtpAppender.SmtpAuthentication.None,
BufferSize = 512,
From = "",
To = "",
Layout = new PatternLayout(""),
Lossy = true,
Evaluator = new LevelEvaluator(Level.Error)
};
var fileAppender = new FileAppender
{
File = System.Configuration.ConfigurationManager.AppSettings["ExceptionLogFilePath"],
AppendToFile = true,
Layout = new PatternLayout(""),
LockingModel = new FileAppender.MinimalLock() //use the minimal locking model that allows multiple processes to write to the same file
};
BasicConfigurator.Configure(smtpAppender);
}
私の問題は、2つのアペンダー(smtpとfile)を使用したいということです。使用する
BasicConfigurator.Configure(smtpAppender);
最初のものを設定できますが、ファイルアペンダーも設定する必要があります。あなたはそれをする理由を知っていますか?
御時間ありがとうございます :)