本文整理汇总了C#中log4net.Appender.ConsoleAppender类的典型用法代码示例。如果您正苦于以下问题:C# ConsoleAppender类的具体用法?C# ConsoleAppender怎么用?C# ConsoleAppender使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConsoleAppender类属于log4net.Appender命名空间,在下文中一共展示了ConsoleAppender类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
}
开发者ID:julienblin,项目名称:Remora,代码行数:32,代码来源:Program.cs
示例2: ConfigureLogging
static void ConfigureLogging()
{
var consoleAppender = new ConsoleAppender();
consoleAppender.Layout = new PatternLayout("[%date{yyyy-MM-dd HH:mm:ss}] %-5p %c{1} - %m%n");
BasicConfigurator.Configure(consoleAppender);
}
开发者ID:yonglehou,项目名称:RedisLatencyChecker,代码行数:7,代码来源:Program.cs
示例3: 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);
}
开发者ID:wwhitehead,项目名称:ProjectFaolan,代码行数:30,代码来源:Logger.cs
示例4: 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");
}
开发者ID:SimplyChris,项目名称:LibHipChat,代码行数:25,代码来源:LogConfigurator.cs
示例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");
}
开发者ID:joethinh,项目名称:nohros-must,代码行数:31,代码来源:ConsoleLogger.cs
示例6: Main
public static void Main(string[] args)
{
ConsoleAppender consoleAppender = new ConsoleAppender();
consoleAppender.Layout =
new PatternLayout("%date [%thread] %-5level %logger [%property{NDC}] - %message%newline");
log4net.Config.BasicConfigurator.Configure(consoleAppender);
if (args.Length == 0)
{
m_log.Debug("Please specify filename");
return;
}
Program webApp = new Program();
//string myStr = "<!--#include file=\"content-box.html\" -->";
//string result = Processor.Processor.Process(myStr);
//m_log.Debug(result);
string fileName = args[0];
using (StreamReader sr = new StreamReader(fileName))
{
string content = sr.ReadToEnd();
Processor p = new Processor(webApp, null);
string result = p.Process(content);
m_log.Debug(result);
}
}
开发者ID:ffoliveira,项目名称:diva-distribution,代码行数:28,代码来源:Program.cs
示例7: 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;
}
开发者ID:nmpountou,项目名称:Project154,代码行数:31,代码来源:Logger.cs
示例8: Main
public static void Main(string[] args)
{
var consoleAppender = new ConsoleAppender()
{
Layout = new PatternLayout("%message%newline"),
Threshold = Level.Info
};
log4net.Config.BasicConfigurator.Configure(consoleAppender);
var log = LogManager.GetLogger(typeof(SlnFileGenerator));
var fileGenerator = new SlnFileGenerator();
var optionsBuilder = new ArgsOptionsBuilder();
var options = optionsBuilder.Build(args, Directory.GetCurrentDirectory());
if (options.ShowHelp)
{
optionsBuilder.WriteHelpMessage();
return;
}
consoleAppender.Threshold = options.LoggingThreshold;
var solutionPath = fileGenerator.GenerateSolutionFile(options);
if (options.OpenInVisualStudio)
{
log.InfoFormat("Opening {0} in Visual Studio {1}", solutionPath, options.VisualStudioVersion.Year);
VisualStudioIntegration.OpenSolution(solutionPath, options.VisualStudioVersion);
}
}
开发者ID:HKochniss,项目名称:SlimJim,代码行数:30,代码来源:SlimJimMain.cs
示例9: 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
示例10: 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());
}
开发者ID:navaneeth,项目名称:orchestrion,代码行数:34,代码来源:Main.cs
示例11: 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;
}
开发者ID:seyyedi,项目名称:core,代码行数:29,代码来源:LogExtensions.cs
示例12: LogToConsole
public static void LogToConsole()
{
ConsoleAppender consoleAppender = new ConsoleAppender();
consoleAppender.Layout =
new PatternLayout("%date [%thread] %-5level %logger [%property{NDC}] - %message%newline");
log4net.Config.BasicConfigurator.Configure(consoleAppender);
}
开发者ID:CassieEllen,项目名称:opensim,代码行数:7,代码来源:TestLogging.cs
示例13: AddConsoleLogger
public static void AddConsoleLogger()
{
ConsoleAppender consoleLog = new ConsoleAppender();
PatternLayout patternLayout = new PatternLayout(config.PatternFormat);
consoleLog.Layout = patternLayout;
AddAppender(consoleLog);
}
开发者ID:ipduncan,项目名称:Refactor,代码行数:7,代码来源:SimpleLogger.cs
示例14: 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;
}
开发者ID:hallem,项目名称:log4net.RollbarSharp,代码行数:59,代码来源:RollbarAppenderTest.cs
示例15: DataTests
static DataTests()
{
var layout = new PatternLayout("%-6timestamp %-5level - %message%newline");
var appender = new ConsoleAppender { Layout = layout };
layout.ActivateOptions();
appender.ActivateOptions();
BasicConfigurator.Configure(appender);
}
开发者ID:TigerPapaDev,项目名称:named-pipe-wrapper,代码行数:8,代码来源:DataTests.cs
示例16: ConfigureLog4Net
private static void ConfigureLog4Net()
{
var appender = new ConsoleAppender
{
Layout = new log4net.Layout.SimpleLayout()
};
log4net.Config.BasicConfigurator.Configure(appender);
}
开发者ID:tiger2soft,项目名称:bbv.Common,代码行数:8,代码来源:Program.cs
示例17: 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);
}
开发者ID:vorou,项目名称:overseer,代码行数:9,代码来源:LogConfigurator.cs
示例18: SetupLoggingWithoutConfigFile
private static void SetupLoggingWithoutConfigFile()
{
var consoleAppender = new ConsoleAppender
{
Layout = new PatternLayout("%date{HH:mm:ss.fff} - %-5level - %logger || %message%newline"),
Threshold = Level.Info
};
BasicConfigurator.Configure(consoleAppender);
}
开发者ID:AtwooTM,项目名称:Zebus.Samples,代码行数:9,代码来源:SampleBase.cs
示例19: Start
/// <inheritdoc />
public override void Start()
{
base.Start();
Console.WriteLine("Log4NetExtension is starting.");
var appender = new ConsoleAppender { Layout = new PatternLayout { ConversionPattern = "%logger - %message%newline" } };
BasicConfigurator.Configure(appender);
}
开发者ID:ursenzler,项目名称:bbv.Common,代码行数:11,代码来源:Log4netExtension.cs
示例20: 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);
}
开发者ID:emmekappa,项目名称:machine.migrations,代码行数:12,代码来源:Program.cs
注:本文中的log4net.Appender.ConsoleAppender类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论