本文整理汇总了C#中log4net.Appender.ConsoleAppender.ActivateOptions方法的典型用法代码示例。如果您正苦于以下问题:C# ConsoleAppender.ActivateOptions方法的具体用法?C# ConsoleAppender.ActivateOptions怎么用?C# ConsoleAppender.ActivateOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类log4net.Appender.ConsoleAppender
的用法示例。
在下文中一共展示了ConsoleAppender.ActivateOptions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConfigureLog4Net
private static void ConfigureLog4Net()
{
if (ConfigurationManager.GetSection("log4net") == null)
{
var layout = new SimpleLayout();
layout.ActivateOptions();
var consoleAppender = new ConsoleAppender
{
Layout = layout
};
consoleAppender.AddFilter(new LevelRangeFilter
{
LevelMin = Level.Info,
LevelMax = Level.Fatal,
AcceptOnMatch = false
});
consoleAppender.AddFilter(
new LoggerMatchFilter
{
LoggerToMatch = "Remora",
AcceptOnMatch = true
}
);
consoleAppender.AddFilter(new DenyAllFilter());
consoleAppender.ActivateOptions();
BasicConfigurator.Configure(consoleAppender);
}
else
{
XmlConfigurator.Configure();
}
}
示例2: Configure
public void Configure()
{
Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository();
hierarchy.Root.RemoveAllAppenders(); /*Remove any other appenders*/
FileAppender fileAppender = new FileAppender();
fileAppender.AppendToFile = true;
fileAppender.LockingModel = new FileAppender.MinimalLock();
fileAppender.File = _locationProvider.GetFilePath();
PatternLayout pl = new PatternLayout();
pl.ConversionPattern = "%d [%2%t] %-5p [%-10c] %m%n%n";
pl.ActivateOptions();
fileAppender.Layout = pl;
fileAppender.ActivateOptions();
ConsoleAppender consoleAppender = new ConsoleAppender();
consoleAppender.Layout = pl;
consoleAppender.ActivateOptions();
// log4net.Config.BasicConfigurator.Configure(fileAppender);
IAppender[] appenders = {fileAppender, consoleAppender};
log4net.Config.BasicConfigurator.Configure(appenders);
var log = LogManager.GetLogger(GetType());
log.Debug("Logging Configured");
}
示例3: 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);
}
示例4: Setup
public static void Setup()
{
Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository();
PatternLayout patternLayout = new PatternLayout();
patternLayout.ConversionPattern = "%date [%thread] %-5level %logger - %message%newline";
patternLayout.ActivateOptions();
RollingFileAppender roller = new RollingFileAppender();
roller.AppendToFile = false;
roller.File = @"Logs\EventLog.txt";
roller.Layout = patternLayout;
roller.MaxSizeRollBackups = 5;
roller.MaximumFileSize = "1GB";
roller.RollingStyle = RollingFileAppender.RollingMode.Size;
roller.StaticLogFileName = true;
roller.ActivateOptions();
hierarchy.Root.AddAppender(roller);
ConsoleAppender appender = new ConsoleAppender();
appender.Layout = patternLayout;
appender.ActivateOptions();
hierarchy.Root.AddAppender(appender);
MemoryAppender memory = new MemoryAppender();
memory.ActivateOptions();
hierarchy.Root.AddAppender(memory);
hierarchy.Root.Level = Level.Debug;
hierarchy.Configured = true;
}
示例5: Configure
/// <summary>
/// Configures the <see cref="FileLogger"/> logger adding the appenders
/// to the root repository.
/// </summary>
public void Configure() {
// create a new logger into the repository of the current assembly.
ILoggerRepository root_repository =
LogManager.GetRepository(Assembly.GetExecutingAssembly());
Logger nohros_console_logger =
root_repository.GetLogger("NohrosConsoleLogger") as Logger;
// create the layout and appender for on error messages.
PatternLayout layout = new PatternLayout();
layout.ConversionPattern = layout_pattern_;
layout.ActivateOptions();
// create the appender
ConsoleAppender appender = new ConsoleAppender();
appender.Name = "NohrosCommonConsoleAppender";
appender.Layout = layout;
appender.Target = "Console.Out";
appender.Threshold = Level.All;
appender.ActivateOptions();
nohros_console_logger.Parent.AddAppender(appender);
root_repository.Configured = true;
logger = LogManager.GetLogger("NohrosConsoleLogger");
}
示例6: ConfigureLogging
static void ConfigureLogging(ServerOptions options)
{
var layout = new PatternLayout("%date %level - %message%newline");
layout.ActivateOptions();
var appenders = new List<IAppender>();
if (!string.IsNullOrEmpty(options.LogFileDirectory))
{
var fileAppender = new FileAppender
{
Layout = layout,
Encoding = Encoding.UTF8,
File = Path.Combine(options.LogFileDirectory, "orchestrion.log"),
AppendToFile = true,
LockingModel = new FileAppender.MinimalLock(),
ImmediateFlush = true,
};
fileAppender.ActivateOptions();
appenders.Add(fileAppender);
}
if (options.ConsoleOutput)
{
var consoleAppender = new ConsoleAppender
{
Layout = layout
};
consoleAppender.ActivateOptions();
appenders.Add(consoleAppender);
}
BasicConfigurator.Configure(appenders.ToArray());
}
示例7: BindConsole
public static void BindConsole(PatternLayout layout = null, Level level = null)
{
layout = layout ?? new PatternLayout
{
ConversionPattern = "%date{ISO8601} %level %logger - %message%newline"
};
layout.ActivateOptions();
var consoleAppender = new ConsoleAppender
{
Name = "console",
Layout = layout
};
consoleAppender.ActivateOptions();
var hierarchy = (Hierarchy)LogManager.GetRepository();
if (hierarchy.Root.GetAppender("console") != null)
{
return;
}
hierarchy.Root.AddAppender(consoleAppender);
hierarchy.Root.Level = level ?? Level.Info;
hierarchy.Configured = true;
}
示例8: Setup
public static void Setup(string path)
{
// "%d[%2%t] %-5p[%-10c] %m %n"
var pl = new PatternLayout {ConversionPattern = "%c%m%n"};
pl.ActivateOptions();
var fileAppender = new FileAppender
{
AppendToFile = true,
LockingModel = new FileAppender.MinimalLock(),
File = path,
Layout = pl
};
fileAppender.ActivateOptions();
var bufferingForwardingAppender = new BufferingForwardingAppender
{
Lossy = false,
Fix = FixFlags.None
};
bufferingForwardingAppender.AddAppender(fileAppender);
bufferingForwardingAppender.ActivateOptions();
var consoleAppender = new ConsoleAppender {Layout = pl};
consoleAppender.ActivateOptions();
var hierarchy = (Hierarchy) LogManager.GetRepository();
hierarchy.Root.RemoveAllAppenders();
BasicConfigurator.Configure(hierarchy, bufferingForwardingAppender, consoleAppender);
}
示例9: SetUpFixture
public void SetUpFixture()
{
Util.LogLog.InternalDebugging = true;
Hierarchy hierarchy = (Hierarchy) LogManager.GetRepository();
PatternLayout patternLayout = new PatternLayout { ConversionPattern = "%d [%t] %-5p %m%n" };
patternLayout.ActivateOptions();
TraceAppender tracer = new TraceAppender { Layout = patternLayout };
tracer.ActivateOptions();
hierarchy.Root.AddAppender(tracer);
ConsoleAppender console = new ConsoleAppender
{
Name = "console",
Layout = patternLayout,
Target = "Console.Out",
Threshold = Level.All,
};
console.ActivateOptions();
hierarchy.Root.AddAppender(console);
RollingFileAppender rollingFile = new RollingFileAppender
{
Name = "file",
Layout = patternLayout,
AppendToFile = true,
RollingStyle = RollingFileAppender.RollingMode.Size,
MaxSizeRollBackups = 4,
MaximumFileSize = "100KB",
StaticLogFileName = true,
LockingModel = new FileAppender.MinimalLock(),
File = "logs\\logFile.txt",
};
rollingFile.ActivateOptions();
hierarchy.Root.AddAppender(rollingFile);
RollbarAppender rollbar = new RollbarAppender
{
Name = "rollbar",
Layout = patternLayout,
AccessToken = "3203880e148b43b4b1a14430fb41957a",
Threshold = Level.Notice,
};
rollbar.ActivateOptions();
hierarchy.Root.AddAppender(rollbar);
hierarchy.Root.Level = Level.All;
hierarchy.Configured = true;
}
示例10: DataTests
static DataTests()
{
var layout = new PatternLayout("%-6timestamp %-5level - %message%newline");
var appender = new ConsoleAppender { Layout = layout };
layout.ActivateOptions();
appender.ActivateOptions();
BasicConfigurator.Configure(appender);
}
示例11: LogToConsoleAnd
public static void LogToConsoleAnd(string logPath)
{
var layout = new PatternLayout("%-5level [%d{HH:mm:ss}] %-20.20logger{1}: %message%newline");
var file = new RollingFileAppender {AppendToFile = false, File = logPath, Layout = layout, Encoding = Encoding.UTF8};
file.ActivateOptions();
var console = new ConsoleAppender {Layout = layout};
console.ActivateOptions();
BasicConfigurator.Configure(console, file);
}
示例12: GetConsoleAppender
private static ConsoleAppender GetConsoleAppender()
{
var consoleAppender = new ConsoleAppender()
{
Name = "ConsoleAppender",
Layout = GetPatternLayout(),
Threshold = Level.Info
};
consoleAppender.ActivateOptions();
return consoleAppender;
}
示例13: SetUpConsole
public static void SetUpConsole(string pattern = DefaultPattern)
{
var layout = new PatternLayout(pattern);
var appender = new ConsoleAppender
{
Layout = layout,
Threshold = Level.Debug
};
layout.ActivateOptions();
appender.ActivateOptions();
BasicConfigurator.Configure(appender);
}
示例14: GetConsoleAppender
private static ConsoleAppender GetConsoleAppender()
{
var appender = new ConsoleAppender
{
Name = "Console",
Layout = new SimpleLayout(),
Threshold = Level.Debug
};
appender.ActivateOptions();
return appender;
}
示例15: Main
public static void Main(string[] args)
{
var appender = new ConsoleAppender() {Layout = new PatternLayout("%-5p %x %m%n")};
appender.ActivateOptions();
BasicConfigurator.Configure(appender);
var program = new Program(new DefaultConsole());
ExitCode exitCode = program.Run(args);
Environment.Exit((int) exitCode);
}