Esempio n. 1
0
        /// <summary>
        /// Configure the log4net
        /// </summary>
        ///  <example>
        /// An example of a logger name = MyApplication
        /// /// </example>
        public static void Configure(string logger, string configFile, LogType type, string appernder)
        {
            logType = type;
            //Gets the logger object
            log = LogManager.GetLogger(logger);

            if (configFile != null && configFile.Length != 0)
            {
                FileInfo fInfo = null;
                try
                {
                    fInfo = new FileInfo(System.Web.HttpRuntime.AppDomainAppPath + @"bin\" + configFile);
                }
                catch
                {
                    fInfo = new FileInfo(@".\" + configFile);
                }

                //Configure the log4net by reading config file
                log4net.Config.XmlConfigurator.Configure(fInfo);
            }
            else
            {
                log4net.Config.XmlConfigurator.Configure();
            }

            //if there is AdoNetAppender, decrypt the connection
            log4net.Repository.Hierarchy.Hierarchy h = LogManager.GetRepository() as log4net.Repository.Hierarchy.Hierarchy;
            if (h != null)
            {
                log4net.Appender.AdoNetAppender adoAppender = (log4net.Appender.AdoNetAppender)h.GetLogger("logger.database", h.LoggerFactory).GetAppender(appernder);
                if (adoAppender != null)
                {
                    EncryptUtility de = new EncryptUtility(EncryptUtility.SymmProvEnum.DES);
                    adoAppender.ConnectionString = de.Decrypting(adoAppender.ConnectionString, ENCRYPTION_KEY);
                    adoAppender.ActivateOptions();
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Configure the log4net
        /// </summary>
        ///  <example>
        /// An example of a logger name = MyApplication
        /// /// </example>
        public static void Configure(string logger, string configFile, LogType type, string appernder)
        {
            logType = type;
            //Gets the logger object
            log = LogManager.GetLogger(logger);

            if (configFile != null && configFile.Length != 0)
            {
                FileInfo fInfo = null;
                try
                {
                    fInfo = new FileInfo(System.Web.HttpRuntime.AppDomainAppPath + @"bin\" + configFile);
                }
                catch
                {
                    fInfo = new FileInfo(@".\" + configFile);
                }

                //Configure the log4net by reading config file
                log4net.Config.DOMConfigurator.Configure(fInfo);
            }
            else
            {
                log4net.Config.DOMConfigurator.Configure();
            }

            //if there is AdoNetAppender, decrypt the connection            
            log4net.Repository.Hierarchy.Hierarchy h = LogManager.GetLoggerRepository() as log4net.Repository.Hierarchy.Hierarchy;
            if (h != null)
            {
                log4net.Appender.ADONetAppender adoAppender = (log4net.Appender.ADONetAppender)h.GetLogger("logger.database", h.LoggerFactory).GetAppender(appernder);
                if (adoAppender != null)
                {
                    EncryptUtility de = new EncryptUtility(EncryptUtility.SymmProvEnum.DES);
                    adoAppender.ConnectionString = de.Decrypting(adoAppender.ConnectionString, ENCRYPTION_KEY);
                    adoAppender.ActivateOptions();
                }
            }
        }