public DataLakeStoreFileSystemClient(IAzureContext context, DataLakeStoreFileSystemCmdletBase cmdlet) : this(context) { bool containsDebug = cmdlet.MyInvocation.BoundParameters.ContainsKey("Debug"); if (containsDebug) { _isDebugEnabled = ((SwitchParameter)cmdlet.MyInvocation.BoundParameters["Debug"]).ToBool(); } else { // The return type of cmdlet.GetVariableValue("DebugPreference") is string when run from a script // return type is System.Management.Automation.ActionPreference when run from commandline var debugPreference = cmdlet.GetVariableValue("DebugPreference").ToString(); if (debugPreference != null) { _isDebugEnabled = !debugPreference.Equals("SilentlyContinue"); } } // Keep this outside if block because it is also used for diagnostic file loggind for BulkCopy _adlsLoggerConfig = new LoggingConfiguration(); if (_isDebugEnabled) { // Custom target that logs the debug messages from the SDK to the powershell framework's debug message queue var adlsTarget = new AdlsLoggerTarget { DebugMessageQueue = cmdlet.DebugMessages }; // Add the target to the configuration _adlsLoggerConfig.AddTarget("logger", adlsTarget); //Logs all patterns of debug messages var rule = new LoggingRule("adls.dotnet.*", NLog.LogLevel.Debug, adlsTarget); _adlsLoggerConfig.LoggingRules.Add(rule); var powershellLoggingRule = new LoggingRule("adls.powershell.WebTransport", NLog.LogLevel.Debug, adlsTarget); _adlsLoggerConfig.LoggingRules.Add(powershellLoggingRule); // Enable the NLog configuration to use this LogManager.Configuration = _adlsLoggerConfig; } }
public DataLakeStoreFileSystemClient(IAzureContext context, DataLakeStoreFileSystemCmdletBase cmdlet) : this(context) { _adlsLoggerConfig = new LoggingConfiguration(); // Custom target that logs the debug messages from the SDK to the powershell framework's debug message queue var adlsTarget = new AdlsLoggerTarget { DebugMessageQueue = cmdlet.DebugMessages }; // Add the target to the configuration _adlsLoggerConfig.AddTarget("logger", adlsTarget); //Logs all patterns of debug messages var rule = new LoggingRule("adls.dotnet.*", NLog.LogLevel.Debug, adlsTarget); _adlsLoggerConfig.LoggingRules.Add(rule); var powershellLoggingRule = new LoggingRule("adls.powershell.WebTransport", NLog.LogLevel.Debug, adlsTarget); _adlsLoggerConfig.LoggingRules.Add(powershellLoggingRule); // Enable the NLog configuration to use this LogManager.Configuration = _adlsLoggerConfig; }