本文整理汇总了C#中IConfiguration.SetSimpleAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# IConfiguration.SetSimpleAttribute方法的具体用法?C# IConfiguration.SetSimpleAttribute怎么用?C# IConfiguration.SetSimpleAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IConfiguration
的用法示例。
在下文中一共展示了IConfiguration.SetSimpleAttribute方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetUp
protected void SetUp()
{
namedMsg = new NamedMessage(MESSAGE, NAMEDMESSAGE, new List<string>(PARAMETER_NAMES),
Level.ERROR);
config = new DefaultConfiguration("default");
config.SetSimpleAttribute("logger_name", LOGGER_NAME);
config.SetSimpleAttribute("default_level", DEFAULT_LEVEL.ToString());
IConfiguration msgsConfig = new DefaultConfiguration("NamedMessages");
IConfiguration msgConfig = new DefaultConfiguration(NAMEDMESSAGE);
msgConfig.SetSimpleAttribute("text", MESSAGE);
msgConfig.SetSimpleAttribute("default_level", Level.DEBUG.ToString());
msgConfig.SetAttribute("parameters", new object[] {PARAMETER_NAMES[0], PARAMETER_NAMES[1]});
msgsConfig.AddChild(msgConfig);
config.AddChild(msgsConfig);
simpleLogger = new SimpleLogger(config);
anotherLogger = new AnotherSimpleLogger(EXCEPTION_LOGGER_NAME);
logger = new ExceptionSafeLogger(simpleLogger, anotherLogger);
}
示例2: InitializeZeroConfiguration
/// <summary>
/// <para>
/// Initializes the diagnostic backend for the zero configuration logging option.
/// </para>
/// <para>
/// System.Diagnostic output does not go to log files, nor is there the same level of control
/// (rolling logs, etc) as offered by log4NET. So all zero-configuration options are treated the
/// same by this class, and no setup of System.Diagnostics is performed.
/// </para>
/// <para>
/// The one action we do take is if the "source" property is not in the configuration, we put the
/// value "TopCoder Logger" as the value of this property into the configuration.
/// </para>
/// <para>
/// New in 3.0.
/// </para>
/// </summary>
/// <param name="option">The option about which zero-configuration setup should be configured in
/// the backend.</param>
/// <param name="configuration">The configuration object to which needed configuration settings are
/// added.</param>
/// <exception cref="ArgumentNullException">If configuration is null.</exception>
/// <exception cref="ConfigException">
/// If any error occurs when accessing the configuration.
/// </exception>
public static void InitializeZeroConfiguration(ZeroConfigurationOption option,
IConfiguration configuration)
{
Helper.ValidateNotNull(configuration, "configuration");
try
{
if (configuration.GetSimpleAttribute(SOURCE) == null)
{
// set the property to default value in configuration
configuration.SetSimpleAttribute(SOURCE, DEFAULT_SOURCE);
}
}
catch (Exception e)
{
throw new ConfigException("Error occurs when accessing the configuration", e);
}
}
示例3: SetUp
protected void SetUp()
{
namedMsg = new NamedMessage(MESSAGE, NAMEDMESSAGE, new List<string>(PARAMETER_NAMES),
Level.ERROR);
config = new DefaultConfiguration("default");
config.SetSimpleAttribute("logger_name", LOGNAME);
config.SetSimpleAttribute("default_level", DEFAULT_LEVEL.ToString());
config.SetSimpleAttribute("config_file", CONFIG_FILE);
IConfiguration msgsConfig = new DefaultConfiguration("NamedMessages");
IConfiguration msgConfig = new DefaultConfiguration(NAMEDMESSAGE);
msgConfig.SetSimpleAttribute("text", MESSAGE);
msgConfig.SetSimpleAttribute("default_level", Level.DEBUG);
msgConfig.SetAttribute("parameters", new object[] {PARAMETER_NAMES[0], PARAMETER_NAMES[1]});
msgsConfig.AddChild(msgConfig);
config.AddChild(msgsConfig);
logger = new Log4NETImpl(config);
}
示例4: SetUp
protected void SetUp()
{
config = new DefaultConfiguration("default");
config.SetSimpleAttribute("logger_name", TestHelper.LOG_NAME);
config.SetSimpleAttribute("default_level", DEFAULT_LEVEL.ToString());
config.SetSimpleAttribute("source", SOURCE);
logger = new DiagnosticImpl(config);
}
示例5: InitializeZeroConfiguration
/// <summary>
/// <para>
/// Initializes the configuration. Sets attribute "isInitiaized" in configuration to true.
/// </para>
/// </summary>
/// <param name="option">The option about which zero-configuration setup should be configured in
/// the backend.</param>
/// <param name="configuration">The configuration object to which needed configuration settings are
/// added.</param>
public static void InitializeZeroConfiguration(ZeroConfigurationOption option,
IConfiguration configuration)
{
configuration.SetSimpleAttribute("isInitiaized", "true");
}
示例6: SetUp
protected void SetUp()
{
IList<string> param = new List<string>();
param.Add("param1");
param.Add("param2");
namedMsg = new NamedMessage("text1", NAME1, param, Level.ERROR);
msgs = new Dictionary<string, NamedMessage>();
msgs.Add(NAME1, namedMsg);
msgs.Add(NAME2, new NamedMessage("text2", NAME2, new List<string>(), Level.WARN));
config = new DefaultConfiguration("default");
config.SetSimpleAttribute("logger_name", LOGNAME);
config.SetSimpleAttribute("default_level", LEVEL.ToString());
IConfiguration msgsConfig = new DefaultConfiguration("NamedMessages");
IConfiguration msgConfig = new DefaultConfiguration(NAME1);
msgConfig.SetSimpleAttribute("text", "text1");
msgConfig.SetSimpleAttribute("default_level", Level.ERROR);
msgConfig.SetAttribute("parameters", new object[] {"param1", "param2"});
msgsConfig.AddChild(msgConfig);
msgConfig = new DefaultConfiguration(NAME2);
msgConfig.SetSimpleAttribute("text", "text2");
msgConfig.SetSimpleAttribute("default_level", Level.WARN);
msgsConfig.AddChild(msgConfig);
config.AddChild(msgsConfig);
logger = new SimpleLogger(LOGNAME, LEVEL, msgs);
}
示例7: InitializeZeroConfiguration
/// <summary>
/// <para>
/// Initializes the log4Net backend for the zero configuration logging option.
/// </para>
/// <para>
/// If the "config_file" property is not in the configuration, the value "log4net.config" will be
/// put as the value of this property into the configuration.
/// </para>
/// <para>
/// If the config file does not exist, an appropriate log4Net configuration file will be written
/// out to this location according to the zero-configuration option:
/// </para>
/// <list type="bullet">
/// <item>
/// <term>Test</term>
/// <description>The configuration uses a FileAppender that writes to the file
/// ../../test_files/log.txt.</description>
/// </item>
/// <item>
/// <term>Component</term>
/// <description>The configuration uses a FileAppender that writes to the file ./log.txt.
/// </description>
/// </item>
/// <item>
/// <term>Certification</term>
/// <description>The configuration uses a RollingFileAppender to write to the logs folder.
/// Files will be rolled over daily, using a pattern of ¡°yyyy-mm-dd" for the files. The
/// configuration is set up so as never to delete old logs.
/// </description>
/// </item>
/// <item>
/// <term> Client Debug</term>
/// <description>This is the same as certification, but configured to keep only the 30 most recent
/// logs.</description>
/// </item>
/// <item>
/// <term>Client Stress</term>
/// <description>This is the same as client debug, but configured so that only messages at the
/// Level.Error (this is the log4net level) or higher are recorded.</description>
/// </item>
/// <item>
/// <term>Release</term>
/// <description>This is the same as client debug, but configured so that only messages at the
/// Level.Warn (this.is the log4net level) or higher are recorded.</description>
/// </item>
/// </list>
/// <para>
/// If the config file does exist, we assume it is from a previous run and do not alter it.
/// </para>
/// <para>
/// New in 3.0.
/// </para>
/// </summary>
/// <param name="option">The option about which zero-configuration setup should be configured in
/// the backend.</param>
/// <param name="configuration">The configuration object to which needed configuration settings are
/// added.</param>
/// <exception cref="ArgumentNullException">If configuration is null.</exception>
/// <exception cref="ConfigException">
/// If any error occurs when accessing the configuration or writing the configuration file.
/// </exception>
public static void InitializeZeroConfiguration(ZeroConfigurationOption option,
IConfiguration configuration)
{
Helper.ValidateNotNull(configuration, "configuration");
// load the config file from configuration (optional)
string configFile = Helper.GetStringAttribute(configuration, CONFIG_FILE, false);
// set the property to default value in configuration if not present
if (configFile == null)
{
configFile = DEFAULT_CONFIG_FILE;
try
{
configuration.SetSimpleAttribute(CONFIG_FILE, configFile);
}
catch (Exception e)
{
throw new ConfigException("Error occurs when accessing the configuration", e);
}
}
// check the config file exist or not
if (!File.Exists(configFile))
{
try
{
// create a log4Net configuration file
using (XmlTextWriter writer = new XmlTextWriter(configFile, null))
{
// enable indent
writer.Formatting = Formatting.Indented;
// write the configuration file
WriteConfigFile(writer, option);
writer.Flush();
}
}
//.........这里部分代码省略.........