Skip to content

Conversation

sfc-gh-ext-simba-lf
Copy link
Collaborator

Description

Remove the log4net dependency and replace with the Microsoft logging interface so users can plug in their own custom loggers

Checklist

  • Code compiles correctly
  • Code is formatted according to Coding Conventions
  • Created tests which fail without the change (if possible)
  • All tests passing (dotnet test)
  • Extended the README / documentation, if necessary
  • Provide JIRA issue id (if possible) or GitHub issue id in PR name

…nector-net into SNOW-834781-Remove-log4net

# Conflicts:
#	Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs
#	Snowflake.Data.Tests/UnitTests/Configuration/EasyLoggingConfigFinderTest.cs
#	Snowflake.Data/Core/ArrowResultSet.cs
#	Snowflake.Data/Core/FileTransfer/StorageClient/SFGCSClient.cs
#	Snowflake.Data/Core/HttpUtil.cs
#	Snowflake.Data/Core/SFBlockingChunkDownloaderV3.cs
#	Snowflake.Data/Core/SFStatement.cs
Copy link

codecov bot commented Nov 13, 2024

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
2858 1 2857 115
View the top 1 failed test(s) by shortest run time
Snowflake.Data.Tests.IntegrationTests.SFConnectionITAsync::TestAsyncLoginTimeout
Stack Traces | 8.42s run time
at Snowflake.Data.Tests.IntegrationTests.SFConnectionITAsync.TestAsyncLoginTimeout() in D:\a\snowflake-connector-net\snowflake-connector-net\Snowflake.Data.Tests\IntegrationTests\SFConnectionIT.cs:line 2010

1)    at Snowflake.Data.Tests.IntegrationTests.SFConnectionITAsync.TestAsyncLoginTimeout() in D:\a\snowflake-connector-net\snowflake-connector-net\Snowflake.Data.Tests\IntegrationTests\SFConnectionIT.cs:line 2010

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@sfc-gh-ext-simba-lf sfc-gh-ext-simba-lf marked this pull request as ready for review November 13, 2024 19:23
@sfc-gh-ext-simba-lf sfc-gh-ext-simba-lf requested a review from a team as a code owner November 13, 2024 19:23
@@ -24,9 +24,10 @@
<PackageReference Include="Google.Cloud.Storage.V1" Version="4.10.0" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.13.0" />
<PackageReference Include="Azure.Storage.Common" Version="12.12.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.1" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use 9.0.5

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to 9.0.5

@@ -24,9 +24,10 @@
<PackageReference Include="Google.Cloud.Storage.V1" Version="4.10.0" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.13.0" />
<PackageReference Include="Azure.Storage.Common" Version="12.12.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="9.0.1" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is not needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.1" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.14" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use 5.5.0

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to 5.5.0

<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="RichardSzalay.MockHttp" Version="6.0.0" />
<PackageReference Include="Serilog" Version="4.0.1" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use 4.3.0

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to 4.3.0

<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="RichardSzalay.MockHttp" Version="6.0.0" />
<PackageReference Include="Serilog" Version="4.0.1" />
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use 9.0.2

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to 9.0.2

<PackageReference Include="Serilog" Version="4.0.1" />
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Serilog.Settings.Xml" Version="1.1.0" />
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use 7.0.0

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to 7.0.0

else
{
var fileInfo = new UnixFileInfo(path: LogFilePath);
using (var handle = fileInfo.Open(FileMode.Append, FileAccess.ReadWrite, FilePermissions.S_IWUSR | FilePermissions.S_IRUSR))
Copy link
Collaborator

@sfc-gh-knozderko sfc-gh-knozderko Jun 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this appender is used only by easy logging. And I think some users would find 600 permissions too restrictive. So I would like to make it configurable in EasyLogging config.
Currently we have the configuration file like that:

{
  "common": {
    "log_level": "DEBUG",
    "log_path": "/path/to/log/directory"
  }
}

we could add a "dotnet" section and "log_file_unix_permissions" field in it:

{
  "common": {
    "log_level": "DEBUG",
    "log_path": "/path/to/log/directory"
  },
  "dotnet": {
    "log_file_unix_permissions": "640"
  }
}

and then we could create the file with such permissions and verify if the permissions are not broader that specified in the config file.
If such permissions would not be configured in the config file then we could assume 600 as the default value.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the PR to include the changes mentioned above:

  • Add dotnet section and log_file_unix_permissions to config file
  • Create file with log_file_unix_permissions permissions and use those permissions for validating when reading/writing the log file
  • Use 600 as the default value for log_file_unix_permissions if not configured. Also uses 600 if the value in the config is invalid

Please let me know if there's any edits you'd like to make

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the chmod of the file is changed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reverted the mode change. It shouldn't have been added in the changes

Copy link
Collaborator

@sfc-gh-pbulawa sfc-gh-pbulawa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the chmods of the files change?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the chmod of the file is changed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reverted the mode change for this one as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants