예제 #1
0
        private void ConfigureLog4Net()
        {
            Hierarchy hierarchy = (Hierarchy)LogManager.GetRepository();

            // output to be in XML
            XmlLayout xmlLayout = new XmlLayout();

            xmlLayout.ActivateOptions();

            // use rolling log file
            RollingFileAppender roll = new RollingFileAppender();

            roll.AppendToFile       = false;
            roll.File               = _config.LogDirectory + "\\" + _config.LogFilePrefix + ".xml";
            roll.Layout             = xmlLayout;
            roll.MaxSizeRollBackups = 5;

            string maxFileSize = "10";

            if (_config.MaxLogFileSize > 0)
            {
                maxFileSize = _config.MaxLogFileSize.ToString();
            }

            roll.MaximumFileSize   = maxFileSize + "MB";
            roll.RollingStyle      = RollingFileAppender.RollingMode.Size;
            roll.StaticLogFileName = true;
            roll.ActivateOptions();
            hierarchy.Root.AddAppender(roll);

            hierarchy.Root.Level = Level.Info;
            hierarchy.Configured = true;
        }
예제 #2
0
        public void ActivateOptions()
        {
            _xmlLayout = new XmlLayout {
                Prefix = null
            };
            _xmlLayout.ActivateOptions();

            _encoding = Encoding.UTF8;
        }