मेरी web.config
में मेरे पास है:मैं वर्तमान ट्रेस स्विच को प्रोग्रामिक रूप से कैसे प्राप्त कर सकता हूं?
<system.diagnostics>
<switches>
<add name="logLevelSwitch" value="1" />
</switches>
</system.diagnostics>
वहाँ एक रास्ता है कि मैं कह सकते है, उदाहरण के लिए:
System.Diagnostics.TraceSwitch["logLevelSwitch"]
वर्तमान मूल्य प्राप्त करने के लिए? ,
private static TraceSwitch logSwitch = new TraceSwitch("logLevelSwitch",
"This is your logLevelSwitch in the config file");
public static void Main(string[] args)
{
// you can get its properties value then:
Console.WriteLine("Trace switch {0} is configured as {1}",
logSwitch.DisplayName,
logSwitch.Level.ToString());
// and you can use it like this:
if (logSwitch.TraceError)
Trace.WriteLine("This is an error");
// or like this also:
Trace.WriteLineIf(logSwitch.TraceWarning, "This is a warning");
}
इसके अलावा, इस काम करने के लिए अनुसार:
क्या आपको इसके लिए कोई समाधान मिला? –