public static void ChangeRollingFileName() { // ログファイル log4net.ILog iLog = log4net.LogManager.GetLogger("AppLogger"); // パス string strPath = Environment.GetEnvironmentVariables()["USERPROFILE"].ToString() + "\\log\\"; string strFilename = strPath + "log.txt"; // 文件夹生成 if (!Directory.Exists(strPath)) { Directory.CreateDirectory(strPath); } log4net.Core.LogImpl logImpl = iLog as log4net.Core.LogImpl; if (logImpl != null) { log4net.Appender.AppenderCollection ac = ((log4net.Repository.Hierarchy.Logger)logImpl.Logger).Appenders; for (int i = 0; i < ac.Count; i++) { // log4net.Appender.FileAppender rfa = ac[i] as log4net.Appender.FileAppender; if (rfa != null) { rfa.File = strFilename; // 写文件 rfa.Writer = new System.IO.StreamWriter(rfa.File, rfa.AppendToFile, rfa.Encoding); } } } 如何调用:=================================================================== 调用class public static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private void TestChangeLog4netLogFileName() { ChangeLog4netLogFileName(); iLog.Info("Test:info"); } configue 的配置===================================================================