public static ILog GetLogger(string path, Type type) { if (!_isConfigured) { if (!string.IsNullOrEmpty(path)) { FileInfo fileInfo = new FileInfo(path); if (fileInfo.Exists) { DOMConfigurator.Configure(fileInfo); } else { DOMConfigurator.Configure(); } } else { DOMConfigurator.Configure(); } _isConfigured = true; } return(LogManager.GetLogger(type)); }
static void Main(string[] args) { DOMConfigurator.Configure(); using (new ForeverLoggingClass()) { Console.WriteLine("Will keep logging a message per second."); Console.ReadLine(); } LogManager.Shutdown(); }
public void OneCanUseLog4Net() { // BasicConfigurator.Configure(); DOMConfigurator.Configure(); logger.Debug("Here is a debug log."); logger.Info("... and an Info log."); logger.Warn("... and a warning."); logger.Error("... and an error."); logger.Fatal("... and a fatal error."); }
public static ILog GetLogger(string name) { if (!_isConfigured) { DOMConfigurator.Configure(); _isConfigured = true; } return(LogManager.GetLogger(name)); }
private void LogSomething() { #region LoggerUsage DOMConfigurator.Configure(); //tis configures the logger logger.Debug("Here is a debug log."); logger.Info("... and an Info log."); logger.Warn("... and a warning."); logger.Error("... and an error."); logger.Fatal("... and a fatal error."); #endregion LoggerUsage }
public string HelloWorld() { DOMConfigurator.Configure(); logger.Debug("Here is a debug log"); logger.Info("... and an Info log."); logger.Warn("... and a warning."); logger.Error("... and an error."); logger.Fatal("... and a fatal error."); return("Hello World"); }
static Log4net() { string path; if (HttpContext.Current != null) { path = HttpContext.Current.Server.MapPath("log4net.config"); } else { path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "log4net.config"); } DOMConfigurator.Configure(new FileInfo(path)); }
private static void Main(string[] args) { // Log to console window //BasicConfigurator.Configure(); // Configure logging to xml file DOMConfigurator.Configure(); logger.Debug("Here is a debug log."); logger.Info("... and an Info log."); logger.Warn("... and a warning."); logger.Error("... and an error."); logger.Fatal("... and a fatal error."); }
public void SetsAppenderPropertiesFromConfig() { var doc = CreateLog4NetXmlConfigurationDocument(facility: "test-system"); DOMConfigurator.Configure(doc.DocumentElement); var appender = LogManager.GetLoggerRepository(Assembly.GetCallingAssembly()).GetAppenders().First(); var gelfAppender = (GelfRabbitMqAppender)appender; Assert.That(gelfAppender, Is.Not.Null); Assert.That(gelfAppender.VirtualHost, Is.EqualTo("/")); Assert.That(gelfAppender.Facility, Is.EqualTo("test-system")); LogManager.Shutdown(); }
static LogHelper() { //Configure log4net try { //If repository is already configured, skip this step. if (!LogManager.GetLoggerRepository(Assembly.GetExecutingAssembly()).Configured) { //Look in our assembly same folder or Machine.config' DOMConfigurator.ConfigureAndWatch(new FileInfo(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "log4net.config"))); } } catch (Exception e) { EventLogHelper.WriteLogEntry(e.Message, EventLogEntryType.Warning); } }
public static void Main(string[] args) { try { UIManager.LookAndFeel = UIManager.SystemLookAndFeelClassName; } catch (Exception e) { Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); } System.setProperty("log4j.properties", confFile); DOMConfigurator.configure(confFile); System.Out = new PrintStream(new LoggingOutputStream(Logger.getLogger("sysout"), Level.INFO)); (new LogWindow()).Visible = true; }
static void Main(string[] args) { Console.WriteLine(" START "); #region LoggerUsage DOMConfigurator.Configure(); //tis configures the logger logger.Debug("Here is a debug log."); logger.Info("... and an Info log."); logger.Warn("... and a warning."); logger.Error("... and an error."); logger.Fatal("... and a fatal error."); #endregion LoggerUsage TestClass objTestClass = new TestClass(); objTestClass.TestMethodNameOK(); objTestClass.TestMethodNameNOK(); Console.WriteLine(" END HIT A KEY TO EXIT "); Console.ReadLine(); } //eof method
static Log() { if (File.Exists(Log4NetConfigFile)) { if (Environment.OSVersion.Platform == PlatformID.Win32NT) { DOMConfigurator.ConfigureAndWatch(new FileInfo(Log4NetConfigFile)); } else { DOMConfigurator.Configure(new FileInfo(Log4NetConfigFile)); } } else { BasicConfigurator.Configure(); } Logger = GetLogger(typeof(Log)); }
private void button1_Click(object sender, EventArgs e) { DOMConfigurator.Configure(); logger.Debug("Here is a debug log."); logger.Info("... and an Info log."); logger.Warn("... and a warning."); logger.Error("... and an error."); logger.Fatal("... and a fatal error."); MySqlConnection conn = null; try { conn = new MySqlConnection(DbManager.connectionString); conn.Open(); MySqlCommand cmd = new MySqlCommand(); cmd.Connection = conn; cmd.CommandText = "INSERT INTO drugs(drug_name,amount) VALUES(@Name,@Amount)"; cmd.Prepare(); cmd.Parameters.AddWithValue("@Name", "Trygve Gulbranssen"); cmd.Parameters.AddWithValue("@Amount", 2); cmd.ExecuteNonQuery(); } catch (MySqlException ex) { logger.Fatal(ex.ToString()); Console.WriteLine("Error: {0}", ex.ToString()); MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (conn != null) { conn.Close(); } } }
public virtual void run() { DOMConfigurator.configure("LogSettings.xml"); System.Out = new PrintStream(new LoggingOutputStream(Logger.getLogger("emu"), Level.INFO)); Screen.HasScreen = false; //IoFileMgrForUser.defaultTimings.get(IoFileMgrForUser.IoOperation.iodevctl).setDelayMillis(0); Modules.sceDisplayModule.setCalledFromCommandLine(); try { runImpl(); } catch (Exception o) { Console.WriteLine(o.ToString()); Console.Write(o.StackTrace); } Environment.Exit(0); }
/// <summary> /// Конфигурирование подсистемы логгирования (log4net) /// </summary> /// <returns></returns> private static bool ConfigureLoggingSubsystem() { var _result = true; try { #pragma warning disable 612,618 DOMConfigurator.Configure(); #pragma warning restore 612,618 } catch (Exception e) { _result = false; if (INTERACTIVE) { Console.WriteLine(e.ToString()); } PrintFooter(); } return(_result); }
static Logger() { BasicConfigurator.Configure(); DOMConfigurator.Configure(); //logger.Debug("Here is a debug log."); //logger.Info("... and an Info log."); //logger.Warn("... and a warning."); //logger.Error("... and an error."); //logger.Fatal("... and a fatal error.") _timerThread = new System.Threading.Timer((o) => { // Stop the timer; _timerThread.Change(-1, -1); // Process your data LogErrorIntoDb(); // start timer again (BeginTime, Interval) _timerThread.Change(_period, _period); }, null, 0, _period); }
protected override void OnStartup(StartupEventArgs e) { DOMConfigurator.Configure(); Logger.Info("Witty is starting."); CheckForCorruptedConfigFile(); Properties.Settings appSettings = Witty.Properties.Settings.Default; if (appSettings.UpgradeSettings) { Witty.Properties.Settings.Default.Upgrade(); appSettings.UpgradeSettings = false; } // Set the default proxy here once and for all (should then be used by // WPF controls, like images that fetch their source from the internet) if (appSettings.UseProxy) { HttpWebRequest.DefaultWebProxy = WebProxyHelper.GetConfiguredWebProxy(); } if (!string.IsNullOrEmpty(appSettings.Skin)) { try { SkinsManager.ChangeSkin(appSettings.Skin); } catch { Logger.Error("Selected skin " + appSettings.Skin + " + not found"); // REVIEW: Should witty do something smart here? } } base.OnStartup(e); }
public static void ClassSetUp(TestContext c) { context = c; DOMConfigurator.Configure(); }
public LoggerInstance() { DOMConfigurator.Configure(); }
public static void SetConfig(FileInfo configFile) { DOMConfigurator.Configure(configFile); }
public static void SetConfig() { DOMConfigurator.Configure(); }
public void Setup() { DOMConfigurator.Configure((XmlElement)ConfigurationManager.GetSection("log4net")); _logger = LogManager.GetLogger(typeof(LogglyAppenderTest)); }
static LogHelper() { DOMConfigurator.Configure(); SetLoggingState(false); }
static LogTest2() { DOMConfigurator.Configure(); }
static void Main(string[] args) { #pragma warning disable CS0618 // Typ oder Element ist veraltet DOMConfigurator.Configure(); #pragma warning restore CS0618 // Typ oder Element ist veraltet Program.Logger.Info("Logger initialized!"); Program.Logger.Debug(string.Format("Args[{0}]: {1}", args.Length, args.Length > 0 ? string.Join(", ", args.Select(x => "\"" + x + "\"").ToArray()) : "<none>")); string name = ""; Mode mode = Mode.Start; if (args.Length == 1 && args[0].StartsWith("-")) { switch (args[0]) { case "--help": case "-h": PrintUsage(); break; case "--version": case "-v": var a = Assembly.GetExecutingAssembly(); Console.WriteLine("{0} v{1}\n", a.GetName().Name, a.GetName().Version); break; case "--list": case "-l": Manager = new ServerManager(CONFIG_FILE); foreach (var cfg in Manager.Configurations) { Console.WriteLine("\t{0}", cfg); } break; default: break; } return; } if (args.Length != 2) { Program.Logger.Error("Expected 2 arguments"); return; } else { name = args[1]; if (!Enum.TryParse(args[0], out mode)) { Program.Logger.Error("Invalid mode \"" + args[0] + "\""); return; } } Manager = new ServerManager(CONFIG_FILE); Manager.Update(); Manager.Handle(name, mode); Program.Logger.Info("Exiting..."); }
private void initLogger() { DOMConfigurator.Configure(); }
public TFSWorkItemMigrationUI() { InitializeComponent(); DOMConfigurator.Configure(); }
static void Main(string[] args) { DOMConfigurator.Configure(new System.IO.FileInfo("log4net-config.xml")); log.Info("Entering application."); log.Info("Exiting application."); }
static void Main(string[] args) { DOMConfigurator.Configure(); //tis configures the logger Animal dog = new Animal() { Name = "Fido", ID = 1 }; Vegetable carrot = new Vegetable { Color = "Orange", Identifier = 2, IsTasty = true }; Mineral carbon = new Mineral() { UniqueID = 3, IsPoisonousToAnimal = false, Name = "some" }; HolderForStrings hfs = new HolderForStrings() { ID = 4, Value = "user_name", MetaName = "meta_nam" }; HolderForStrings hfs1 = new HolderForStrings() { ID = 5, Value = "user_name", MetaName = "hfs1" }; Mineral carbon1 = new Mineral() { UniqueID = 3, IsPoisonousToAnimal = false, Name = "some1" }; pool.AddItem(dog); pool.AddItem(carrot); pool.AddItem(hfs); pool.AddItem(hfs1); //pool.AddItem<Animal>(dog.ID, dog); //pool.AddItem<Vegetable>(carrot.Identifier, carrot); //pool.AddItem<Mineral> ( carbon ); //pool.AddItem<HolderForStrings> ( 1, hfs ); //logger.Info("Dog is in the pool -- this statement is " + pool.ContainsKey<Animal>(dog.ID)); //logger.Info("hfs is in the pool -- this statement is " + pool.ContainsKey<HolderForStrings>(hfs.ID)); //logger.Info("The hfs value is from the poos is " + pool.GetItem<HolderForStrings>(4).Value); //logger.Info("poo.GetItems is " + pool.GetItems<HolderForStrings>()); #region while //for (int i = 0; i < pool.Count -1 ; i++) int i = 1; do { try { logger.Info("counting"); logger.Info(" i is " + i.ToString()); if (pool.ContainsKey <Animal> (i)) { logger.Info(" I see animal which is " + pool.GetItem <Animal> (i).Name); } if (pool.ContainsKey <Vegetable> (i)) { logger.Info(" I see Vegetable which is " + pool.GetItem <Vegetable> (i).Color); } if (pool.ContainsKey <Mineral> (i)) { logger.Info(" I see Mineral which is " + pool.GetItem <Mineral> (i).IsPoisonousToAnimal); } if (pool.ContainsKey <HolderForStrings> (i)) { logger.Info(" I see string which is " + pool.GetItem <HolderForStrings> (i).Value); } //logger.Info("pool.GetItem<HolderForStrings>(4).Value); is " + pool.GetItem<Object>(i).ToString()); i = i + 1; } catch (KeyNotFoundException e) { continue; } } //eof for while (i < pool.TotalCount); #endregion while #region AddHolders ////this is the success identifier //HoldInt16 holdVerifier = new HoldInt16() //{ // ID=0 , // MetaName = "ret", // Value = 0 //}; //pool.AddItem<HoldInt16>(holdVerifier.ID, holdVerifier); //ListDictionary lidMetaName = pool.LidMetaName; ////this is the message //HoldString holdMsg = new HoldString( ref lidMetaName) //{ // ID=1, // MetaName = "msg", // Value = msg, // Title = "title" //}; //pool.AddItem<HoldString>(holdMsg.ID, holdMsg); //HoldString holdmmsg = new HoldString(ref lidMetaName) //{ // ID=2, // MetaName = "mmsg", // Value = "mmsg" , // Title = "title" //}; #endregion AddHolders //Utils.Debugger.DebugListDictionary(ref msg, "domainName", ref lidMetaName); //get the value be metaName logger.Info("I queried the pool by property with meta Value and value user_name "); HolderForStrings HolderForStrings = pool.GetItemByPropertyValue <HolderForStrings> ("MetaName", "hfs1"); //logger.Info ( "object dump" + Utils.Log.ObjDumper.DumpObject ( HolderForStrings ) ); logger.Info("I found the following value for property with the name \"Name\" "); logger.Info(HolderForStrings.MetaName); Console.ReadLine(); } //eof Main