static void Main(string[] args) { // Previously this would could throw an exception if permission issues or an invalid network drive occurred var logWriter = new LogWriterFactory().Create(); // This will throw the exception encountered during initialization above but the exception will be // attempted to be logged to the errors special source (in this project the Event Log under the // source Enterprise Library Logging) and the exception swallowed logWriter.Write("To be...", "Failure Category"); // This will create a logs directory and write to rolling.log file in the logs directory logWriter.Write("or not to be.", "Success Category"); }
static void Main(string[] args) { //从Data.config配置文件获取设置 DatabaseProviderFactory dbFactory = new DatabaseProviderFactory(GetFileConfigurationSource("Data Configuration Source")); Database db = dbFactory.Create("Connection String"); Console.WriteLine(db.ConnectionString); //从Log.config的配置文件获取设置 LogWriter lw = new LogWriterFactory(GetFileConfigurationSource("Log Configuration Source")).Create(); lw.Write("123"); }
static void Main(string[] args) { var logger = new LogWriterFactory().Create(); // log for 10 minutes...config is set to keep 7 files for (int i = 0; i < 10; i++) { Console.Write("\nWriting log"); logger.Write("Testing!", "General"); for (int j = 0; j < 60; j++) { System.Threading.Thread.Sleep(1000); Console.Write("."); } } }