CyberSource / cybersource-rest-client-dotnet

.NET client library for the CyberSource REST API
Other
19 stars 44 forks source link

IsMaskingEnabled from July 2021 Update causing failures if NLog not setup and/or enableMasking undocumented variable not present #117

Open xantari opened 3 years ago

xantari commented 3 years ago

Your code doesn't indicate you have to setup NLog anywhere.

When it's not setup the entire nuget fails to load anything. It seems you have to not only setup NLog now, you also have to add a magic undocumented variable (had to search the source code to find it) called "enableMasking" and set it to true or false because your code doesn't do existence checking.

Stack trace when all undocumented variables and NLog setup not performed:

at AuthenticationSdk.util.LogUtility.IsMaskingEnabled(Logger logger) at CyberSource.Client.ApiClient.CallApi(String path, Method method, Dictionary2 queryParams, Object postBody, Dictionary2 headerParams, Dictionary2 formParams, Dictionary2 fileParams, Dictionary2 pathParams, String contentType) at CyberSource.Api.ReportsApi.SearchReportsWithHttpInfo(Nullable1 startTime, Nullable1 endTime, String timeQueryType, String organizationId, String reportMimeType, String reportFrequency, String reportName, Nullable1 reportDefinitionId, String reportStatus) at ARRT.Payments.Services.Vendors.CyberSource.CyberSourceGateway.d__1.MoveNext() in C:\TFS\ARRT.All.Projects\ARRT.Payments.Services\Vendors\CyberSource\CyberSourceGateway.cs:line 65

wrightsonm commented 3 years ago

Another NLog issue to be aware of is this:

AuthenticationSdk.util.LogUtility expects "file" target to be set in NLog if FileTarget "file" is not set the AuthenticationSDK will disable logging which will disable logging for our entire application, not just cybersource

This is our workaround:

            if (!NLog.LogManager.Configuration.AllTargets.Any((t) => string.Equals(t.Name,"file")))
            {
                var fileTarget = new NLog.Targets.FileTarget("file") { FileName = "file.log" };
                NLog.LogManager.Configuration.AddTarget("file", fileTarget);
            }
xantari commented 3 years ago

That's crazy, didn't know that. Definitely shouldn't be expected behavior.

wrightsonm commented 2 years ago

NLog.LogManager.Configuration.Variables.Add("enableMasking", new NLog.Layouts.SimpleLayout("true"));