Exemplo n.º 1
0
        static Log()
        {
            Config = LogConfigManager.Config;
            PatternLayout layout;
            AppenderSkeleton appender;

            switch (Config.Type)
            {
                case LogType.ConfigFromLogFile:
                    XmlConfigurator.ConfigureAndWatch(new FileInfo(Config.FileName));
                    break;
                case LogType.RollingFile:
                case LogType.RollingFileAndWinEventLog:
                    layout = new PatternLayout(Config.Pattern);
                    appender = new RollingFileAppender
                    {
                        File = Config.FileName,
                        AppendToFile = true,
                        RollingStyle = RollingFileAppender.RollingMode.Composite,
                        MaxSizeRollBackups = Config.MaxNumberOfBackupFiles,// App.Config.IsDebugConfiguration ? -1 : 100,
                        MaximumFileSize = Config.RollingFileMaximumFileSize,
                        DatePattern = Config.RollingFileDatePattern,
                        Layout = layout,
                        LockingModel = new FileAppender.MinimalLock()
                    };
                    layout.ActivateOptions();
                    appender.ActivateOptions();
                    BasicConfigurator.Configure(appender);
                    break;
                default:
                    if (Config.Type == LogType.WinEventLog ||
                        Config.Type == LogType.RollingFileAndWinEventLog)
                    {
                        layout = new PatternLayout(Config.Pattern);
                        appender = new EventLogAppender
                        {
                            LogName = App.Config.Name,
                            Layout = layout
                        };
                        layout.ActivateOptions();
                        appender.ActivateOptions();
                        BasicConfigurator.Configure(appender);
                    }
                    else if (Config.Type == LogType.VisualStudioTraceOutput)
                    {
                        layout = new PatternLayout(Config.Pattern);
                        appender = new TraceAppender
                        {
                            ImmediateFlush = true
                        };
                        layout.ActivateOptions();
                        appender.ActivateOptions();
                        appender.Layout = layout;
                        BasicConfigurator.Configure(appender);
                    }
                    break;
            }
        }
Exemplo n.º 2
0
 private static void PerformStartup()
 {
     LogConfig.InitializeLog4Net();
     InitializeSessionFactory();
     InitializeRepositories();
 }