コード例 #1
0
ファイル: ELSImpl.cs プロジェクト: bage/Demo-Logging-Wrapper
 /// <summary>
 /// <para>
 /// Creates a new ElSImpl instance with setting loaded from given configuration.
 /// </para>
 /// </summary>
 /// <param name="configuration">The configuration object to load settings from.</param>
 /// <exception cref="ArgumentNullException">If the configuration is null.</exception>
 /// <exception cref="ConfigException">If any of the configuration settings are missing or are
 /// invalid values, or if there is an exception when instantiating the logging service.</exception>
 public ELSImpl(IConfiguration configuration)
     : base(configuration)
 {
     try
     {
         // instantiate the logging service with basic http binding and given url as endpoint
         // loggingService = new LoggingServiceClient(new BasicHttpBinding(), new EndpointAddress(url));
         ConfigurationAPIObjectFactory of =
             new ConfigurationAPIObjectFactory(configuration);
         loggingService = (ILoggingService)of.CreateDefinedObject(SERVICECONFIGURATIONKEY);
     }
     catch (Exception e)
     {
         throw new ConfigException("Fail to instantiate the logging service.", e);
     }
 }
コード例 #2
0
        /// <summary>
        /// <para>
        /// Constructor for creating an appender programmatically with given logging service.
        /// </para>
        /// </summary>
        /// <param name="serviceConfiguration">The configuration that the appender is created from.</param>
        /// <exception cref="ArgumentNullException">If service is null.</exception>
        public ELSAppender(IConfiguration serviceConfiguration)
            : base()
        {
            Helper.ValidateNotNull(serviceConfiguration, "serviceConfiguration");

            try
            {
                ConfigurationAPIObjectFactory of =
                    new ConfigurationAPIObjectFactory(serviceConfiguration);
                loggingService = (ILoggingService)of.CreateDefinedObject(SERVICECONFIGURATIONKEY);
            }
            catch (Exception e)
            {
                throw new ConfigException("Failed to create the service client.", e);
            }
        }