Which two code segments should you use? (Each correct answer presents part of the solution

You are creating an XML Web service named BankCustomer that provides bank customer information. You write code to keep track of error messages, warning messages, and informational messages while the service is running. You use the Trace class to write the messages to a log file.

On test computers, you want to see error messages and warning messages. On deployment computers, you want to see error messages, but not warning messages.

Which two code segments should you use? (Each correct answer presents part of the solution. Choose two.)

You are creating an XML Web service named BankCustomer that provides bank customer information. You write code to keep track of error messages, warning messages, and informational messages while the service is running. You use the Trace class to write the messages to a log file.

On test computers, you want to see error messages and warning messages. On deployment computers, you want to see error messages, but not warning messages.

Which two code segments should you use? (Each correct answer presents part of the solution. Choose two.)

A.
private static TraceSwitch mySwitch;
static BankCustomer {
mySwitch = new TraceSwitch(“tswitch”,
“a trace switch”);
}

B.
public static TraceLevel level;
static BankCustomer {
level = TraceLevel.Error;
}

C.
Trace.WriteLineIf(mySwitch.TraceError,
“An error occurred.”);
Trace.WriteLineIf(mySwitch.TraceWarning,
“Warning message”);

D.
Trace.WriteLineIf(level == TraceLevel.Error ,
“The operation succeeded.”);
Trace.WriteLineIf(level == TraceLevel.Warning ,
“Warning message”);

E.
Trace.WriteLineIf(mySwitch != null,
“An error occurred.”);
Trace.WriteLineIf(mySwitch != null,
“Warning message”);

F.
Trace.WriteIf(level != TraceLevel.Off,
“An error occurred.”);
Trace.WriteIf(level != TraceLevel.Off,
“Warning message”);



Leave a Reply 0

Your email address will not be published. Required fields are marked *