This class allows for the creation of a trace service instance based on the log4net framework.
상속: ILogServiceFactory, ILogServiceAppendable
예제 #1
0
        private static void ConfigureLog4Net(string filename)
        {
            if (log4netConfiguredYet)
            {
                return;
            }

            InitializeApplicationName();
            if (!string.IsNullOrEmpty(filename))
            {
                var file = new FileInfo(filename);
                if (file != null)
                {
                    global::log4net.Config.XmlConfigurator.Configure(file);
                    log4netConfiguredYet = true;
                }
            }

            // maybe we have config in the app.config file?
            if (!log4netConfiguredYet)
            {
                global::log4net.Config.XmlConfigurator.Configure();
                log4netConfiguredYet = true;
            }

            // Forces initialization
            var initialLogger = Log4NetServiceFactory.CreateService(null);
        }
예제 #2
0
 /// <summary>
 /// Obtains an instance of the logger service for the specified type and optional additional data.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="additionalData">The additional data.</param>
 /// <returns>
 /// An implementation of <see cref="ILogService"/>.
 /// </returns>
 public ILogService GetLogger(Type type, IDictionary <string, object> additionalData = null)
 {
     // We do nothing with the additional data at the moment.
     return(Log4NetServiceFactory.CreateService(type));
 }