Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Serilog Dependency + Log to File #289

Draft
wants to merge 19 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed .DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore

# OS-specific files
.DS_Store

# User-specific files
*.suo
*.user
Expand Down
Binary file removed IPPDotNetDevKitCSV3/.DS_Store
Binary file not shown.
101 changes: 0 additions & 101 deletions IPPDotNetDevKitCSV3/Code/Intuit.Ipp.Core.Test/LogRequestsToDiskTest.cs

This file was deleted.

30 changes: 0 additions & 30 deletions IPPDotNetDevKitCSV3/Code/Intuit.Ipp.Core/AppSettings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
{
"Logger": {
"RequestLog": {
"EnableLogs": "false",
"LogDirectory": ""
}
},
//not supported -added for backward compatibility
"CustomLogger": {
Expand All @@ -13,32 +9,6 @@
"Type": ""
}
},
"SeriLogger": {
"RequestSerilog": {
"Debug": {
"EnableLogs": "true"
},
"Trace": {
"EnableLogs": "true"
},
"Console:": {
"Enable": "true"
},
"File": {
"Enable": "true",
"LogDirectory": ""
},
"AzureDocumentDB": {
"Enable": "true",
"Url": "",
"SecureKey": "",
"TimeToLive": ""
}



}
},
"Security": {
"Mode": {
"Oauth": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,9 @@ namespace Intuit.Ipp.Core.Configuration
public class AdvancedLogger
{
/// <summary>
/// Gets or sets the Request logging mechanism.
/// Gets or sets the <see cref="IAdvancedLogger"/>.
/// </summary>
public RequestAdvancedLog RequestAdvancedLog { get; set; }



public IAdvancedLogger Logger { get; set; }
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace Intuit.Ipp.Core.Configuration
public class IppConfiguration
{
/// <summary>
/// Gets or sets the Serilog Logger mechanism.
/// Gets or sets the Advanced Logger mechanism.
/// </summary>
public AdvancedLogger AdvancedLogger { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,11 @@ public IppConfiguration GetConfiguration()
IppConfiguration ippConfig = new IppConfiguration();

#if !NETSTANDARD2_0
//initializing the Advanced Serilogger
IppConfigurationSection ippConfigurationSection = IppConfigurationSection.Instance;

ippConfig.AdvancedLogger = new AdvancedLogger
{

RequestAdvancedLog = new RequestAdvancedLog()
{
EnableSerilogRequestResponseLoggingForDebug = false,
EnableSerilogRequestResponseLoggingForTrace = false,
EnableSerilogRequestResponseLoggingForConsole = false,
EnableSerilogRequestResponseLoggingForFile = false,
ServiceRequestLoggingLocationForFile = System.IO.Path.GetTempPath()
}
Logger = new TraceLogger(),
};

if (ippConfigurationSection == null)
Expand All @@ -115,11 +106,6 @@ public IppConfiguration GetConfiguration()
ippConfig.Logger = new Logger
{
CustomLogger = new TraceLogger(),
RequestLog = new RequestLog
{
EnableRequestResponseLogging = false,
ServiceRequestLoggingLocation = System.IO.Path.GetTempPath()
}
};

ippConfig.Message = new Message
Expand Down Expand Up @@ -160,23 +146,6 @@ public IppConfiguration GetConfiguration()
}

ippConfig.Logger = new Logger();
ippConfig.Logger.RequestLog = new RequestLog();
ippConfig.Logger.RequestLog.EnableRequestResponseLogging = ippConfigurationSection.Logger.RequestLog.EnableRequestResponseLogging;
if (string.IsNullOrEmpty(ippConfigurationSection.Logger.RequestLog.RequestResponseLoggingDirectory))
{
ippConfig.Logger.RequestLog.ServiceRequestLoggingLocation = Path.GetTempPath();
}
else
{
string location = ippConfigurationSection.Logger.RequestLog.RequestResponseLoggingDirectory;
if (!Directory.Exists(location))
{
IdsException exception = new IdsException(Properties.Resources.ValidDirectoryPathMessage, new DirectoryNotFoundException());
IdsExceptionManager.HandleException(exception);
}

ippConfig.Logger.RequestLog.ServiceRequestLoggingLocation = ippConfigurationSection.Logger.RequestLog.RequestResponseLoggingDirectory;
}

if (!string.IsNullOrEmpty(ippConfigurationSection.Logger.CustomLogger.Name) && !string.IsNullOrEmpty(ippConfigurationSection.Logger.CustomLogger.Type) && ippConfigurationSection.Logger.CustomLogger.Enable)
{
Expand Down Expand Up @@ -355,26 +324,13 @@ public IppConfiguration GetConfiguration()

ippConfig.AdvancedLogger = new AdvancedLogger
{

RequestAdvancedLog = new RequestAdvancedLog()
{
EnableSerilogRequestResponseLoggingForDebug = false,
EnableSerilogRequestResponseLoggingForTrace = false,
EnableSerilogRequestResponseLoggingForConsole = false,
EnableSerilogRequestResponseLoggingForFile = false,
ServiceRequestLoggingLocationForFile = System.IO.Path.GetTempPath()
}
Logger = new TraceLogger(),
};


ippConfig.Logger = new Logger
{
CustomLogger = new TraceLogger(),
RequestLog = new RequestLog
{
EnableRequestResponseLogging = false,
ServiceRequestLoggingLocation = System.IO.Path.GetTempPath()
}
};

ippConfig.Message = new Message
Expand Down Expand Up @@ -417,7 +373,6 @@ public IppConfiguration GetConfiguration()


//Read all appsettings.json sections
var loggerSettings = builder.GetSection("Logger").GetSection("RequestLog");
var customLoggerSettings = builder.GetSection("CustomLogger").GetSection("RequestLog");
var securitySettings = builder.GetSection("Security").GetSection("Mode");
var securityOauthSettings = builder.GetSection("Security").GetSection("Mode").GetSection("OAuth");
Expand All @@ -432,91 +387,6 @@ public IppConfiguration GetConfiguration()
var serviceBaseUrlSettings = builder.GetSection("Service").GetSection("BaseUrl");
var serviceMinorversionSettings = builder.GetSection("Service").GetSection("Minorversion");
var webhooksVerifierTokenSettings = builder.GetSection("WebhooksService").GetSection("VerifierToken");
var serilogLoggerSettings = builder.GetSection("SeriLogger").GetSection("RequestSerilog");
var serilogLoggerSettingsDebug = builder.GetSection("SeriLogger").GetSection("RequestSerilog").GetSection("Debug");
var serilogLoggerSettingsConsole = builder.GetSection("SeriLogger").GetSection("RequestSerilog").GetSection("Console");
var serilogLoggerSettingsFile = builder.GetSection("SeriLogger").GetSection("RequestSerilog").GetSection("File");



#region support later

//if (!string.IsNullOrEmpty(serilogLoggerSettingsAzureDocumentDB["LogDirectory"]) && Convert.ToBoolean(serilogLoggerSettingsAzureDocumentDB["EnableLogs"]) == true)
//{


// ippConfig.AdvancedLogger.RequestAdvancedLog.EnableSerilogRequestResponseLoggingForAzureDocumentDB = Convert.ToBoolean(serilogLoggerSettingsAzureDocumentDB["EnableLogs"]);


// string url = serilogLoggerSettingsAzureDocumentDB["Url"];
// Uri parsedUrl = new Uri(url);
// string secureKey = serilogLoggerSettingsAzureDocumentDB["SecureKey"];

// if (string.IsNullOrEmpty(url))
// {
// IdsException exception = new IdsException(Properties.Resources.AzureDocumentDBSecureKeyNullEmptyMessage, new ArgumentNullException());
// IdsExceptionManager.HandleException(exception);
// }
// if (string.IsNullOrEmpty(secureKey))
// {
// IdsException exception = new IdsException(Properties.Resources.AzureDocumentDBSecureKeyNullEmptyMessage, new ArgumentNullException());
// IdsExceptionManager.HandleException(exception);
// }


// if (string.IsNullOrEmpty(serilogLoggerSettingsAzureDocumentDB["TimeToLive"]))
// {
// ippConfig.AdvancedLogger.RequestAdvancedLog.ServiceRequestAzureDocumentDBTTL = 7;//Defaulted to last 7 days logs
// }
// else
// {
// ippConfig.AdvancedLogger.RequestAdvancedLog.ServiceRequestAzureDocumentDBTTL = Convert.ToInt32(serilogLoggerSettingsAzureDocumentDB["TimeToLive"]);
// }

// ippConfig.AdvancedLogger.RequestAdvancedLog.ServiceRequestAzureDocumentDBUrl = parsedUrl;
// ippConfig.AdvancedLogger.RequestAdvancedLog.ServiceRequestAzureDocumentDBSecureKey = secureKey;


//}

#endregion

if (!string.IsNullOrEmpty(serilogLoggerSettingsFile["LogDirectory"]) && Convert.ToBoolean(serilogLoggerSettingsFile["EnableLogs"]) == true)
{



ippConfig.AdvancedLogger.RequestAdvancedLog.EnableSerilogRequestResponseLoggingForFile = Convert.ToBoolean(serilogLoggerSettingsFile["EnableLogs"]);


string location = loggerSettings["LogDirectory"];
if (!Directory.Exists(location))
{
IdsException exception = new IdsException(Properties.Resources.ValidDirectoryPathMessage, new DirectoryNotFoundException());
IdsExceptionManager.HandleException(exception);
}

ippConfig.AdvancedLogger.RequestAdvancedLog.ServiceRequestLoggingLocationForFile = serilogLoggerSettingsFile["LogDirectory"];

}

//old logger
if (!string.IsNullOrEmpty(loggerSettings["LogDirectory"]) && Convert.ToBoolean(loggerSettings["EnableLogs"]) == true)
{

ippConfig.Logger.RequestLog.EnableRequestResponseLogging = Convert.ToBoolean(loggerSettings["EnableLogs"]);


string location = loggerSettings["LogDirectory"];
if (!Directory.Exists(location))
{
IdsException exception = new IdsException(Properties.Resources.ValidDirectoryPathMessage, new DirectoryNotFoundException());
IdsExceptionManager.HandleException(exception);
}

ippConfig.Logger.RequestLog.ServiceRequestLoggingLocation = loggerSettings["LogDirectory"];

}

if (!string.IsNullOrEmpty(customLoggerSettings["Name"]) && !string.IsNullOrEmpty(customLoggerSettings["Type"]) && Convert.ToBoolean(customLoggerSettings["Enable"]) == true)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ namespace Intuit.Ipp.Core.Configuration
/// </summary>
public class Logger
{
/// <summary>
/// Gets or sets the Request logging mechanism.
/// </summary>
public RequestLog RequestLog { get; set; }

/// <summary>
/// Gets or sets the Custom logger implementation class.
/// </summary>
Expand Down
Loading