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); }
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"); }
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(); } }
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); }
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); } }
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); } }
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); }
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; }
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()); }
/// <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"); }
public static void AddConsoleLogger() { ConsoleAppender consoleLog = new ConsoleAppender(); PatternLayout patternLayout = new PatternLayout(config.PatternFormat); consoleLog.Layout = patternLayout; AddAppender(consoleLog); }
static ConsoleAppender CreateConsoleAppender() { log4net.Appender.ConsoleAppender rfa = new log4net.Appender.ConsoleAppender(); rfa.Name = "ConsoleAppender"; rfa.Layout = new log4net.Layout.PatternLayout("Time:%date ThreadID:[%thread] LogLevel:%-5level %nMessage:%message%n%newline"); return(rfa); }
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; }
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); }
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; }
private static void ConfigureLog4Net() { var appender = new ConsoleAppender { Layout = new log4net.Layout.SimpleLayout() }; log4net.Config.BasicConfigurator.Configure(appender); }
static DataTests() { var layout = new PatternLayout("%-6timestamp %-5level - %message%newline"); var appender = new ConsoleAppender { Layout = layout }; layout.ActivateOptions(); appender.ActivateOptions(); BasicConfigurator.Configure(appender); }
protected static void SetupLogging(int loglevel) { // console appender log4net.Appender.ConsoleAppender appender; appender = new log4net.Appender.ConsoleAppender(); switch (loglevel) { case 0: appender.Threshold = log4net.Core.Level.Error; break; case 1: appender.Threshold = log4net.Core.Level.Warn; break; case 2: appender.Threshold = log4net.Core.Level.Info; break; case 3: appender.Threshold = log4net.Core.Level.Debug; break; case 4: appender.Threshold = log4net.Core.Level.All; break; } string pattern_layout; if (loglevel <= 1) { pattern_layout = "[%-5level] %message%newline"; } else { pattern_layout = "%-4utcdate{yy/MM/dd_HH:mm:ss.fff} [%-5level] %logger->%M - %message%newline"; } appender.Layout = new log4net.Layout.PatternLayout(pattern_layout); log4net.Config.BasicConfigurator.Configure(appender); logger = LogManager.GetLogger("Main"); logger.Debug("logsystem initialized"); if (loglevel >= 3) { var appender2 = new log4net.Appender.FileAppender(appender.Layout, "./debug.log", true); log4net.Config.BasicConfigurator.Configure(appender2); logger.Debug("Writing all log messages to file: debug.log"); } /* ColoredConsoleAppender is win32 only. A managed version was introduced to log4net svn * and should be available when log4net 1.2.12 comes out. * * Below codes is not tested/working! * * log4net.Appender.ColoredConsoleAppender appender; * appender = new log4net.Appender.ColoredConsoleAppender (); * appender.Layout = new log4net.Layout.PatternLayout ("%date [%thread] %-5level %logger [%property{NDC}] - %message%newline"); * log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo("/Users/td/log4net.config")); * colors.BackColor = log4net.Appender.ColoredConsoleAppender.Colors.HighIntensity; * colors.ForeColor = log4net.Appender.ColoredConsoleAppender.Colors.Blue; * colors.Level = log4net.Core.Level.Debug; * appender.AddMapping(colors); */ }
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); }
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); }
/// <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); }
private static ConsoleAppender GetConsoleAppender() { var consoleAppender = new log4net.Appender.ConsoleAppender() { Name = "ConsoleAppender", Layout = GetPatternLayout(), Threshold = Level.All }; consoleAppender.ActivateOptions(); return(consoleAppender); }
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); }
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); }
private static void AddNLogConsoleOutput() { var repository = (Hierarchy) LogManager.GetRepository(); var appender = new ConsoleAppender { Layout = new PatternLayout("%date %-5level [%ndc] - %message%newline") }; repository.Root.AddAppender(appender); repository.Configured = true; repository.RaiseConfigurationChanged(EventArgs.Empty); appender.Threshold = Level.Debug; }
private static ConsoleAppender GetConsoleAppender() { var consoleAppender = new ConsoleAppender() { Name = "ConsoleAppender", Layout = GetPatternLayout(), Threshold = Level.Info }; consoleAppender.ActivateOptions(); return consoleAppender; }
private static ConsoleAppender GetConsoleAppender() { var appender = new ConsoleAppender { Name = "Console", Layout = new SimpleLayout(), Threshold = Level.Debug }; appender.ActivateOptions(); return appender; }
private static IAppender set_up_console_appender() { ConsoleAppender appender = new ConsoleAppender(); appender.Name = "ConsoleAppender"; PatternLayout pattern_layout = new PatternLayout("%message%newline"); pattern_layout.ActivateOptions(); appender.Layout = pattern_layout; appender.ActivateOptions(); return appender; }
static dwLog() { logger = LogManager.GetLogger("DetWorld"); //string layoutPattern = "%date{HH:mm:ss} [%thread] %-5level %logger - %message%newline"; string layoutPattern = "%message%newline"; PatternLayout layout = new PatternLayout(layoutPattern); ConsoleAppender appender = new ConsoleAppender(); appender.Layout = layout; BasicConfigurator.Configure(appender); }
public static void Main(string[] args) { ConsoleAppender consoleAppender = new ConsoleAppender(); consoleAppender.Layout = new PatternLayout("[%thread] - %message%newline"); log4net.Config.BasicConfigurator.Configure(consoleAppender); string serverURI = "http://127.0.0.1:8003"; if (args.Length > 1) serverURI = args[1]; int max1, max2; ThreadPool.GetMaxThreads(out max1, out max2); m_log.InfoFormat("[ASSET CLIENT]: Connecting to {0} max threads = {1} - {2}", serverURI, max1, max2); ThreadPool.GetMinThreads(out max1, out max2); m_log.InfoFormat("[ASSET CLIENT]: Connecting to {0} min threads = {1} - {2}", serverURI, max1, max2); if (!ThreadPool.SetMinThreads(1, 1)) m_log.WarnFormat("[ASSET CLIENT]: Failed to set min threads"); if (!ThreadPool.SetMaxThreads(10, 3)) m_log.WarnFormat("[ASSET CLIENT]: Failed to set max threads"); ThreadPool.GetMaxThreads(out max1, out max2); m_log.InfoFormat("[ASSET CLIENT]: Post set max threads = {1} - {2}", serverURI, max1, max2); ThreadPool.GetMinThreads(out max1, out max2); m_log.InfoFormat("[ASSET CLIENT]: Post set min threads = {1} - {2}", serverURI, max1, max2); ServicePointManager.DefaultConnectionLimit = 12; AssetServicesConnector m_Connector = new AssetServicesConnector(serverURI); m_Connector.MaxAssetRequestConcurrency = 30; for (int i = 0; i < NREQS; i++) { UUID uuid = UUID.Random(); m_Connector.Get(uuid.ToString(), null, ResponseReceived); m_log.InfoFormat("[ASSET CLIENT]: [{0}] requested asset {1}", i, uuid); } for (int i = 0; i < 500; i++) { var x = i; ThreadPool.QueueUserWorkItem(delegate { Dummy(x); }); } Thread.Sleep(30 * 1000); m_log.InfoFormat("[ASSET CLIENT]: Received responses {0}", m_NReceived); }
internal static ConsoleAppender BuildConsoleLog(LogOptions options) { var layout = new PatternLayout { ConversionPattern = options.Pattern }; layout.ActivateOptions(); var appender = new ConsoleAppender { Layout = layout }; appender.ActivateOptions(); return appender; }
public void BeforeAnyTestsRun() { //We'll create a logger so that we can log out all of the //tests. //TODO: MAYBE MOVE THIS CONFIGURATION INTO AN XML FILE AT SOME POINT ConsoleAppender console = new ConsoleAppender(); console.Layout = new PatternLayout(); console.Threshold = log4net.Core.Level.Debug; //Ensure any repositories are shutdown before creating a new one. ShutDownAllRepositories(); log4net.Config.BasicConfigurator.Configure(console); }
public static ILog GetLogger(Type type) { if (_consoleAppender == null) _consoleAppender = GetConsoleAppender(); if (_rollingFileAppender == null) _rollingFileAppender = GetRollingFileAppender(); if (_logger != null) return _logger; BasicConfigurator.Configure(_consoleAppender, _rollingFileAppender); _logger = LogManager.GetLogger(type); return _logger; }
public void BasicConfig() { PatternLayout layout = new PatternLayout(); layout.ConversionPattern = "%date [%thread] %-5level %C{2} %M - %message%newline"; layout.ActivateOptions(); //the ColoredConsoleAppender is not available in mono so use a standard console appender #if __MonoCS__ log4net.Appender.ConsoleAppender appender = new log4net.Appender.ConsoleAppender(); appender.Layout = layout; appender.ActivateOptions(); BasicConfigurator.Configure(appender); #else log4net.Appender.ColoredConsoleAppender appender = new log4net.Appender.ColoredConsoleAppender(); appender.Layout = layout; ColoredConsoleAppender.LevelColors errorMapping = new ColoredConsoleAppender.LevelColors(); errorMapping.BackColor = ColoredConsoleAppender.Colors.HighIntensity | ColoredConsoleAppender.Colors.Red; errorMapping.ForeColor = ColoredConsoleAppender.Colors.White; errorMapping.Level = Level.Error; ColoredConsoleAppender.LevelColors infoMapping = new ColoredConsoleAppender.LevelColors(); infoMapping.ForeColor = ColoredConsoleAppender.Colors.Green; infoMapping.Level = Level.Info; ColoredConsoleAppender.LevelColors debugMapping = new ColoredConsoleAppender.LevelColors(); debugMapping.ForeColor = ColoredConsoleAppender.Colors.Blue; debugMapping.Level = Level.Debug; appender.AddMapping(errorMapping); appender.AddMapping(infoMapping); appender.AddMapping(debugMapping); appender.ActivateOptions(); BasicConfigurator.Configure(appender); #endif }