本文整理汇总了C#中log4net.Appender.RollingFileAppender类的典型用法代码示例。如果您正苦于以下问题:C# RollingFileAppender类的具体用法?C# RollingFileAppender怎么用?C# RollingFileAppender使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RollingFileAppender类属于log4net.Appender命名空间,在下文中一共展示了RollingFileAppender类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: LogConfig
public LogConfig()
{
rootLevel = log4net.Core.Level.Debug;
patternLayout = new PatternLayout();
patternLayout.ConversionPattern = "%d %-7p [TID=%3t] %m%n";
consoleAppender = new ManagedColoredConsoleAppender();
consoleAppender.Layout = patternLayout;
consoleAppender.AddMapping(new ManagedColoredConsoleAppender.LevelColors() { ForeColor = ConsoleColor.Red, BackColor=ConsoleColor.White, Level = log4net.Core.Level.Fatal });
consoleAppender.AddMapping(new ManagedColoredConsoleAppender.LevelColors() { ForeColor = ConsoleColor.Red, Level = log4net.Core.Level.Error});
consoleAppender.AddMapping(new ManagedColoredConsoleAppender.LevelColors() { ForeColor = ConsoleColor.Yellow, Level = log4net.Core.Level.Warn });
consoleAppender.AddMapping(new ManagedColoredConsoleAppender.LevelColors() { ForeColor = ConsoleColor.Green, Level = log4net.Core.Level.Info});
consoleAppender.AddMapping(new ManagedColoredConsoleAppender.LevelColors() { ForeColor = ConsoleColor.White, Level = log4net.Core.Level.Debug});
consoleAppender.AddMapping(new ManagedColoredConsoleAppender.LevelColors() { ForeColor = ConsoleColor.Gray, Level = log4net.Core.Level.Verbose });
rollingAppender = new RollingFileAppender();
rollingAppender.Layout = patternLayout;
rollingAppender.MaxFileSize = 10 * 1048576;
rollingAppender.MaxSizeRollBackups = 20;
rollingAppender.AppendToFile = true;
rollingAppender.RollingStyle = RollingFileAppender.RollingMode.Size;
rollingAppender.StaticLogFileName = true;
rollingAppender.File = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Assembly.GetEntryAssembly().GetName().Name + ".log");
}
开发者ID:fenixio,项目名称:Artisan,代码行数:25,代码来源:LogConfig.cs
示例2: Setup
public static void Setup(string path)
{
var hierarchy = (Hierarchy)LogManager.GetRepository();
var patternLayout = new PatternLayout();
patternLayout.ConversionPattern = "%date [%thread] %-5level %logger - %message%newline";
// patternLayout.ConversionPattern = "%date [%thread] %-5level %logger - %message%newline";
patternLayout.ActivateOptions();
var roller = new RollingFileAppender();
roller.AppendToFile = true;
roller.File = path;
roller.Layout = patternLayout;
roller.MaxSizeRollBackups = 5;
roller.MaximumFileSize = "2MB";
roller.RollingStyle = RollingFileAppender.RollingMode.Size;
roller.StaticLogFileName = true;
roller.ActivateOptions();
hierarchy.Root.AddAppender(roller);
var memory = new MemoryAppender();
memory.ActivateOptions();
hierarchy.Root.AddAppender(memory);
hierarchy.Root.Level = Level.Info;
hierarchy.Configured = true;
}
开发者ID:StefanMihaylov,项目名称:PerforceBackup,代码行数:27,代码来源:Log4netSettings.cs
示例3: RegisterTypes
public static void RegisterTypes(IUnityContainer container)
{
var hierarchy = (Hierarchy)LogManager.GetRepository();
hierarchy.Root.RemoveAllAppenders();
hierarchy.Root.Level = Level.Debug;
hierarchy.RaiseConfigurationChanged(EventArgs.Empty);
FileAppender fileAppender = new RollingFileAppender();
fileAppender.AppendToFile = true;
fileAppender.LockingModel = new FileAppender.MinimalLock();
fileAppender.File = HttpContext.Current.Server.MapPath("~/TestHarness1.log.txt");
var patternLayout = new PatternLayout { ConversionPattern = "%d [%2%t] %-5p [%-10c] %m%n%n" };
patternLayout.ActivateOptions();
fileAppender.Layout = patternLayout;
fileAppender.ActivateOptions();
BasicConfigurator.Configure(fileAppender);
var logger = LogManager.GetLogger(typeof(IServiceBus));
container.RegisterInstance<ILog>(logger, new ContainerControlledLifetimeManager());
var ftpClient = new FtpQueueClient();
ftpClient.ConnectAsync(new Uri("ftp://ftp.jdibble.co.uk/site1/Personal/service-bus-ftp/queue"), new NetworkCredential("jdibble-001", "jli798ik")).Wait();
container.RegisterInstance<IFtpQueueClient>(ftpClient, new ContainerControlledLifetimeManager());
container.RegisterType<IQueueManager, FtpQueueManager>(new ContainerControlledLifetimeManager());
container.RegisterType<SharedMessageHandler>();
var messageDictionary = new MessageTypeDictionary
{
{ ServiceBus.Messaging.MessageExtensions.MessageTypeSignature<SharedMessage>(), typeof(SharedMessage) },
{ ServiceBus.Messaging.MessageExtensions.MessageTypeSignature<NonSharedMessage>(), typeof(NonSharedMessage) },
{ ServiceBus.Messaging.MessageExtensions.MessageTypeSignature<SharedEvent>(), typeof(SharedEvent) }
};
container.RegisterInstance<IMessageSerialiser>(new JsonMessageSerialiser(messageDictionary), new ContainerControlledLifetimeManager());
var serviceBus =
ServiceBusBuilder.Configure()
.WithLogger(container.Resolve<ILog>())
.WithHostAddress(new Uri("http://servicebus-ftp.jdibble.co.uk"))
.WithHttpTransport(new JsonMessageSerialiser(messageDictionary))
.AsMvcServiceBus(RouteTable.Routes, container.Resolve<IQueueManager>())
.Build()
.WithMessageHandler(container.Resolve<SharedMessageHandler>())
.Subscribe(container.Resolve<SharedEventHandler>())
.WithPeerAsync(new Peer(new Uri("http://servicebus-ftp2.jdibble.co.uk"))).Result;
serviceBus.WithPeerAsync(new Peer(new Uri("http://servicebus.jdibble.co.uk")));
serviceBus.WithPeerAsync(new Peer(new Uri("http://servicebus2.jdibble.co.uk")));
container.RegisterInstance(serviceBus, new ContainerControlledLifetimeManager());
container.RegisterType<ServiceBusHub>(new ContainerControlledLifetimeManager());
}
开发者ID:dibble-james,项目名称:ServiceBus,代码行数:60,代码来源:Bootstrapper.cs
示例4: Setup
/// <summary>
/// Configures the log4net environment
/// </summary>
private void Setup(Level logLevel)
{
Directory.CreateDirectory(_logFolder);
var hierarchy = (Hierarchy)LogManager.GetRepository();
// Log to a file
var roller = new RollingFileAppender();
roller.AppendToFile = false;
roller.File = _logFile;
roller.Layout = new PatternLayout("%date %type.%method [%-5level] - %message%newline");
roller.MaxSizeRollBackups = 5;
roller.RollingStyle = RollingFileAppender.RollingMode.Size;
roller.StaticLogFileName = true;
roller.ActivateOptions();
hierarchy.Root.AddAppender(roller);
// Log to the visual studio console
var appender = new TraceAppender();
appender.ActivateOptions();
appender.Layout = new PatternLayout("%method (%line) %date [%-5level] - %message%newline");
hierarchy.Root.AddAppender(appender);
hierarchy.Root.Level = logLevel;
hierarchy.Configured = true;
}
开发者ID:ElderByte-,项目名称:Archimedes.Locco,代码行数:30,代码来源:LoggerConfiguration.cs
示例5: Log4NetLogFactory
public Log4NetLogFactory(LogFileSettings settings)
{
var patternLayout = new log4net.Layout.PatternLayout(
"%date [%thread] %level %logger - %message%newline");
patternLayout.ActivateOptions();
RollingFileAppender appender
= new RollingFileAppender
{
Name = "rolling-appender",
File = Path.Combine(settings.DirectoryPath, settings.NamePrefix + ".log"),
AppendToFile = true,
MaxSizeRollBackups = 10,
RollingStyle = RollingFileAppender.RollingMode.Date,
Layout = patternLayout,
LockingModel = new FileAppender.MinimalLock()
};
appender.ActivateOptions();
log4net.Config.BasicConfigurator.Configure(appender);
Hierarchy h = (Hierarchy)LogManager.GetRepository();
Logger rootLogger = h.Root;
rootLogger.Level = h.LevelMap[ConvertLogLevel(settings.Level).ToString().ToUpper()];
}
开发者ID:DM-TOR,项目名称:nhin-d,代码行数:26,代码来源:Log4NetLogFactory.cs
示例6: Configure
public static void Configure(string appfolder, string logFile)
{
bool isConfigured = _log.Logger.Repository.Configured;
if (!isConfigured)
{
// Setup RollingFileAppender
var fileAppender = new RollingFileAppender
{
Layout =
new PatternLayout(
"%d %level [%type{1}] - %m%n"),
MaximumFileSize = "1000KB",
MaxSizeRollBackups = 10,
RollingStyle = RollingFileAppender.RollingMode.Composite,
AppendToFile = true,
File = logFile,
ImmediateFlush = true,
LockingModel = new FileAppender.MinimalLock(),
Name = "XXXRollingFileAppender",
Threshold = log4net.Core.Level.All
};
fileAppender.ActivateOptions(); // IMPORTANT, creates the file
BasicConfigurator.Configure(fileAppender);
#if DEBUG
// Setup TraceAppender
TraceAppender ta = new TraceAppender();
ta.Layout = new PatternLayout("%d [%t]%-5p %c [%x] - %m%n");
BasicConfigurator.Configure(ta);
#endif
}
}
开发者ID:StephOfPixVert,项目名称:ShootingLab,代码行数:32,代码来源:LabCommonLog.cs
示例7: InitLog
//configure log4Net via code instead of xml
public static void InitLog(string completeLogFile)
{
_filePath = completeLogFile;
var hierarchy = (log4net.Repository.Hierarchy.Hierarchy)LogManager.GetRepository();
hierarchy.Root.RemoveAllAppenders();
var pl = new log4net.Layout.PatternLayout { ConversionPattern = DefaultConversionPatern };
pl.ActivateOptions();
var fileAppender = new RollingFileAppender()
{
AppendToFile = true,
LockingModel = new FileAppender.MinimalLock(),
File = _filePath,
Layout = pl,
};
fileAppender.MaxFileSize = 10 * 1024 * 1024;
fileAppender.RollingStyle = RollingFileAppender.RollingMode.Size;
fileAppender.MaxSizeRollBackups = 5;
fileAppender.ActivateOptions();
BasicConfigurator.Configure(fileAppender);
_logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
}
开发者ID:bpatra,项目名称:Hookmainthread,代码行数:28,代码来源:Log.cs
示例8: SetupLogger
/// <summary>
/// Setups the logger configuration. Can be used instead of loading log4net.config file
/// </summary>
public static void SetupLogger()
{
Hierarchy hierarchy = (Hierarchy) LogManager.GetRepository();
PatternLayout patternLayout = new DynamicPatternLayout();
patternLayout.ConversionPattern = "%date{dd MMM yyyy HH:mm:ss} [%thread] %level - %message %exception %newline";
patternLayout.ActivateOptions();
RollingFileAppender roller = new RollingFileAppender
{
// appends the log into same file
AppendToFile = true,
File = @"DeployLogs\\Deploylog.log",
Layout = patternLayout,
MaxSizeRollBackups = 1000,
RollingStyle = RollingFileAppender.RollingMode.Date,
StaticLogFileName = false
};
roller.ActivateOptions();
hierarchy.Root.AddAppender(roller);
MemoryAppender memoryAppender = new MemoryAppender();
memoryAppender.ActivateOptions();
hierarchy.Root.AddAppender(memoryAppender);
hierarchy.Root.Level = Level.All;
hierarchy.Configured = true;
}
开发者ID:AshikJayaram,项目名称:Deploy,代码行数:33,代码来源:DeployLogger.cs
示例9: Setup
public void Setup()
{
var applicationDataDirectory =
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"PCoMD", "Log");
LogFilePath = Path.Combine(applicationDataDirectory, "PCoMD.xml");
var hierarchy = (Hierarchy) LogManager.GetRepository();
var patternLayout = new XmlLayoutSchemaLog4j();
patternLayout.LocationInfo = true;
patternLayout.ActivateOptions();
var roller = new RollingFileAppender
{
AppendToFile = true,
MaximumFileSize = "2MB",
File = LogFilePath,
PreserveLogFileNameExtension = true,
MaxSizeRollBackups = 10,
RollingStyle = RollingFileAppender.RollingMode.Size,
Layout = patternLayout
};
roller.ActivateOptions();
hierarchy.Root.AddAppender(roller);
var memory = new MemoryAppender();
memory.ActivateOptions();
hierarchy.Root.AddAppender(memory);
hierarchy.Root.Level = Level.Info;
hierarchy.Configured = true;
XmlConfigurator.Configure(hierarchy);
}
开发者ID:flyeven,项目名称:PCoMD,代码行数:35,代码来源:ApplicationLogger.cs
示例10: Logger
static Logger()
{
var hierarchy = (Hierarchy)LogManager.GetRepository();
var tracer = new TraceAppender();
var patternLayout = new PatternLayout {ConversionPattern = LOG_PATTERN};
patternLayout.ActivateOptions();
tracer.Layout = patternLayout;
tracer.ActivateOptions();
hierarchy.Root.AddAppender(tracer);
var roller = new RollingFileAppender
{
Layout = patternLayout,
AppendToFile = true,
RollingStyle = RollingFileAppender.RollingMode.Size,
MaxSizeRollBackups = 4,
MaximumFileSize = "10240KB",
StaticLogFileName = true,
File = FilePath + @"\f1speed-log.txt"
};
roller.ActivateOptions();
hierarchy.Root.AddAppender(roller);
hierarchy.Root.Level = Level.Debug;
hierarchy.Configured = true;
}
开发者ID:Malyngo,项目名称:DirtRallyWebTelemetry,代码行数:28,代码来源:Logging.cs
示例11: InitLog4net
private static void InitLog4net()
{
Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository();
PatternLayout patternLayout = new PatternLayout();
patternLayout.ConversionPattern = "[%date] %-5level [%thread] %property{user} - %message%exception%n";
patternLayout.ActivateOptions();
RollingFileAppender roller = new RollingFileAppender();
roller.AppendToFile = true;
roller.File = @"logs\";
roller.Layout = patternLayout;
roller.MaxSizeRollBackups = 100;
roller.MaximumFileSize = "10MB";
roller.RollingStyle = RollingFileAppender.RollingMode.Date;
roller.DatePattern = "yyyyMMdd'.log'";
roller.StaticLogFileName = false;
roller.ActivateOptions();
hierarchy.Root.AddAppender(roller);
hierarchy.Root.Level = Level.All;
hierarchy.Configured = true;
log4net.GlobalContext.Properties["user"] = new Log4NetUserNameProvider();
}
开发者ID:zhh007,项目名称:CKGen,代码行数:25,代码来源:Bootstrap.cs
示例12: DefaultLogWrapper
public DefaultLogWrapper(string logname, IConfig config)
{
this.logname = logname;
Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository();
hierarchy.Clear();
TraceAppender tracer = new TraceAppender();
PatternLayout patternLayout = new PatternLayout();
patternLayout.ConversionPattern = "%t (%-5level) - %m%n";
patternLayout.ActivateOptions();
tracer.Layout = patternLayout;
tracer.ActivateOptions();
hierarchy.Root.AddAppender(tracer);
RollingFileAppender roller = new RollingFileAppender();
roller.Layout = patternLayout;
roller.AppendToFile = true;
roller.RollingStyle = RollingFileAppender.RollingMode.Size;
roller.MaxSizeRollBackups = 4;
roller.MaximumFileSize = "100KB";
roller.StaticLogFileName = true;
roller.File = Path.Combine(config.IndexFolder, "totalrecall-" + this.logname + ".log");
roller.ActivateOptions();
hierarchy.Root.AddAppender(roller);
hierarchy.Root.Level = Level.All;
hierarchy.Configured = true;
}
开发者ID:riadyb,项目名称:totalrecall,代码行数:31,代码来源:DefaultLogWrapper.cs
示例13: CLogger
/// <summary>
/// constructor that initialize logger name, file name and log level
/// </summary>
public CLogger(string sLoggerName, string sFilename, int iLogLevel)
{
ILog oLogger = LogManager.GetLogger(sLoggerName);
string sLogFileName = string.Empty;
sLogFileName = GetLogFileName(sFilename);
m_oFPLogger = (log4net.Repository.Hierarchy.Logger)oLogger.Logger;
log4net.Appender.RollingFileAppender oFPAppender = new RollingFileAppender();
oFPAppender.File = sLogFileName;
oFPAppender.MaxSizeRollBackups = 100;
oFPAppender.MaximumFileSize = "1MB";
oFPAppender.RollingStyle = RollingFileAppender.RollingMode.Size;
oFPAppender.StaticLogFileName = true;
oFPAppender.AppendToFile = true;
log4net.Layout.PatternLayout layout = new log4net.Layout.PatternLayout();
layout.ConversionPattern = "%d %-5p - %m%n%exception";
layout.ActivateOptions();
oFPAppender.Layout = layout;
oFPAppender.ActivateOptions();
/** Programmatically configuration will not work it it is not set true**/
m_oFPLogger.Hierarchy.Configured = true;
try
{
m_oFPLogger.AddAppender(oFPAppender);
}
catch (Exception ex)
{
throw new Exception("Failed to Add Appender", ex);
}
m_oFPLogger.Hierarchy.Root.Level = m_oFPLogger.Hierarchy.LevelMap[GetLogLevel(iLogLevel)];
oLogger = null;
}
开发者ID:krishnakanthms,项目名称:Online-Exam-tool,代码行数:37,代码来源:CLogger.cs
示例14: Configure
public static void Configure()
{
var hierarchy = (Hierarchy)LogManager.GetRepository();
hierarchy.Root.RemoveAllAppenders();
// see http://logging.apache.org/log4net/release/sdk/log4net.Layout.PatternLayout.html
var layout = new PatternLayout
{
ConversionPattern = "%date{dd-MMM-yyyy HH:mm:ss} %-5level %message%n%exception%n"
};
var fileAppender = new RollingFileAppender
{
Layout = layout,
AppendToFile = true,
File = "log.txt",
LockingModel = new FileAppender.MinimalLock(),
};
var consoleAppender = new ConsoleAppender
{
Layout = layout,
};
layout.ActivateOptions();
fileAppender.ActivateOptions();
log4net.Config.BasicConfigurator.Configure(fileAppender);
consoleAppender.ActivateOptions();
log4net.Config.BasicConfigurator.Configure(consoleAppender);
}
开发者ID:sumothecat,项目名称:Pushbaby,代码行数:33,代码来源:Log4NetConfiguration.cs
示例15: Logger
static Logger()
{
Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository();
TraceAppender tracer = new TraceAppender();
PatternLayout patternLayout = new PatternLayout();
patternLayout.ConversionPattern = LOG_PATTERN;
patternLayout.ActivateOptions();
tracer.Layout = patternLayout;
tracer.ActivateOptions();
hierarchy.Root.AddAppender(tracer);
RollingFileAppender roller = new RollingFileAppender();
roller.Layout = patternLayout;
roller.AppendToFile = true;
roller.RollingStyle = RollingFileAppender.RollingMode.Size;
roller.MaxSizeRollBackups = 4;
roller.MaximumFileSize = "32768KB";
roller.StaticLogFileName = true;
roller.File = "log\\Log.log";
roller.ActivateOptions();
hierarchy.Root.AddAppender(roller);
hierarchy.Root.Level = Level.All;
hierarchy.Configured = true;
}
开发者ID:dionata,项目名称:wfmvc,代码行数:27,代码来源:Logger.cs
示例16: CreateFileAppender
// Create a new file appender
public static RollingFileAppender CreateFileAppender(LoggerConfigurationElement element)
{
var appender = new RollingFileAppender();
appender.Name = element.LoggerName;
appender.File = element.Filename;
appender.AppendToFile = true;
appender.RollingStyle = RollingFileAppender.RollingMode.Composite;
appender.MaximumFileSize = element.MaximumFileSize;
appender.MaxSizeRollBackups = element.MaxSizeRollBackups;
appender.PreserveLogFileNameExtension = element.PreserveLogFileNameExtension;
appender.DatePattern = element.DatePattern;
var layout = new PatternLayout();
layout.ConversionPattern = "%message";
layout.ActivateOptions();
var filter = new LoggerMatchFilter();
filter.LoggerToMatch = element.LoggerName;
filter.ActivateOptions();
var denyAllFilter = new DenyAllFilter();
denyAllFilter.ActivateOptions();
appender.AddFilter(filter);
appender.AddFilter(denyAllFilter);
appender.Layout = layout;
appender.ActivateOptions();
return appender;
}
开发者ID:bisand,项目名称:Graviton,代码行数:32,代码来源:LogConfigurator.cs
示例17: SetupLoggers
private static void SetupLoggers()
{
var hierarchy = (Hierarchy) LogManager.GetRepository();
var patternLayout = new PatternLayout
{
ConversionPattern = "%date [%thread] %-5level %logger - %message%newline"
};
patternLayout.ActivateOptions();
var fileAppender = new RollingFileAppender
{
AppendToFile = false,
File =
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Tailviewer",
"Tailviewer.log"),
Layout = patternLayout,
MaxSizeRollBackups = 20,
MaximumFileSize = "1GB",
RollingStyle = RollingFileAppender.RollingMode.Size,
StaticLogFileName = false
};
fileAppender.ActivateOptions();
hierarchy.Root.AddAppender(fileAppender);
hierarchy.Root.Level = Level.Info;
hierarchy.Configured = true;
}
开发者ID:Kittyfisto,项目名称:Tailviewer,代码行数:28,代码来源:Bootstrapper.cs
示例18: set_file_appender
public static void set_file_appender(string output_directory)
{
if (!already_configured_file_appender)
{
already_configured_file_appender = true;
var layout = new PatternLayout
{
ConversionPattern = "%date [%-5level] - %message%newline"
};
layout.ActivateOptions();
var rollingFileAppender = new RollingFileAppender
{
Name = "roundhouse.changes.log.appender",
File = Path.Combine(Path.GetFullPath(output_directory), "roundhouse.changes.log"),
Layout = layout,
AppendToFile = false
};
rollingFileAppender.ActivateOptions();
var log = LogManager.GetLogger("roundhouse");
var logger = (log4net.Repository.Hierarchy.Logger)log.Logger;
logger.AddAppender(rollingFileAppender);
var nhLog = LogManager.GetLogger("NHibernate.SQL");
var nhLogger = (log4net.Repository.Hierarchy.Logger)nhLog.Logger;
nhLogger.AddAppender(rollingFileAppender);
}
}
开发者ID:Smartrak,项目名称:roundhouse,代码行数:30,代码来源:Log4NetAppender.cs
示例19: SetPath
public void SetPath(String path)
{
//_writer = new StreamWriter(path);
//_path = path;
PatternLayout patternLayout = new PatternLayout
{
ConversionPattern = "[%date] - [%logger] - %level - %message%newline"
};
patternLayout.ActivateOptions();
RollingFileAppender rollingFileAppender = new RollingFileAppender
{
File = path,
Layout = patternLayout,
MaximumFileSize = "5MB",
MaxSizeRollBackups = 2,
PreserveLogFileNameExtension = true,
RollingStyle = RollingFileAppender.RollingMode.Size,
LockingModel = new FileAppender.MinimalLock()
};
rollingFileAppender.ActivateOptions();
Hierarchy hierarchy = LogManager.GetRepository() as Hierarchy;
Logger root = hierarchy.Root;
root.RemoveAllAppenders();
root.Level = Level.All;
BasicConfigurator.Configure(rollingFileAppender);
}
开发者ID:Ledragon,项目名称:VideoPlayer,代码行数:31,代码来源:LoggingSystemManager.cs
示例20: Log
protected Log()
{
#region конфигурирование FileLog
//log4net.Config.XmlConfigurator.Configure();//конфиг не происходит, тк очевидно что у либы не может быть app.config-а,
//а тут он есть, но получается что он "ненастоящий"
var apender = new RollingFileAppender();
apender.File = Path.Combine(Furniture.Helpers.LocalAccounts.modelPathResult, "LogUpd.txt");
if (Path.GetFileName(apender.File) != "LogUpd.txt")
apender.File = Path.Combine(Furniture.Helpers.LocalAccounts.modelPathResult, "\\LogUpd.txt");
//apender.File = "D:\\_SWLIB_\\LogUpd.txt";
apender.AppendToFile = true;
apender.RollingStyle = RollingFileAppender.RollingMode.Size;
apender.MaxSizeRollBackups = 0;
apender.MaximumFileSize = "2MB";
apender.StaticLogFileName = true;
apender.Encoding = Encoding.UTF8;
apender.LockingModel = new FileAppender.MinimalLock();
apender.Layout = new PatternLayout("%date [%thread] %-5level [%property{NDC}] - %message%newline");
apender.ActivateOptions();
FilePath = apender.File;
File.SetAttributes(FilePath, FileAttributes.Normal);
#endregion
log4net.Config.BasicConfigurator.Configure(apender);
log = LogManager.GetLogger(typeof(Log));
}
开发者ID:digger1985,项目名称:MyCode,代码行数:27,代码来源:Log.cs
注:本文中的log4net.Appender.RollingFileAppender类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论