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

AWS S3 SDK always tries to load log4net assembly even if logging is disabled or set to output to console #1839

Closed
1 task
madhub opened this issue Apr 29, 2021 · 4 comments
Labels
bug This issue is a bug. module/sdk-core p2 This is a standard priority issue perf queued xs Effort estimation: tiny

Comments

@madhub
Copy link
Contributor

madhub commented Apr 29, 2021

Description

AWS S3 SDK always tries to load log4net assembly even if logging is disabled or set to output to console

We have application where we provide Assembly Resolver to resolve plugin assemblies, on every application launch our resolver is called to load log4net assembly even if logging is disabled or set to output to console.

Expectation : If logging is disabled or set to output to console , library should try load log4net assembly

Reproduction Steps

public class AWSSample
    {
        private const string DllExtension = ".dll";

        static void Main(string[] args)
        {
            // Assembly Resolver to load Plugin assemblies
            AssemblyLoadContext.Default.Resolving += Default_Resolving;
            string accessKey = "minioadmin";
            string secretKey = "minioadmin"; // do not store secret key hardcoded in your production source code!

            // Setting LoggingOptions.None also tries to load log4net
            AWSConfigs.Logging = LoggingOptions.Console;

            var config = new AmazonS3Config
            {
                RegionEndpoint = RegionEndpoint.USEast1, 
                ServiceURL = "http://localhost:9000", 
                ForcePathStyle = true,

                // disabling logging
                DisableLogging = true,

                Timeout = TimeSpan.FromSeconds(4)

            };
            var amazonS3Client = new AmazonS3Client(accessKey, secretKey, config);
            TransferUtility transferUtility = new TransferUtility(amazonS3Client);
            try
            {
                transferUtility.UploadDirectory(@"C:\Data\docs", "demo");
            }
            catch (Exception exp)
            {
                Console.WriteLine(exp.ToString());
            }

        }

        /// <summary>
        /// Assembly Resolver to load Plugin assemblies
        /// </summary>
        /// <param name="context"></param>
        /// <param name="arg2"></param>
        /// <returns></returns>
        private static System.Reflection.Assembly Default_Resolving(AssemblyLoadContext context, System.Reflection.AssemblyName arg2)
        {
            var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, arg2.Name + DllExtension);
            try
            {
                if (File.Exists(path))
                {
                    return context.LoadFromAssemblyPath(path);
                }

                Console.WriteLine($"Unable to locate {arg2.Name} at {path}");
            }
            catch (Exception e)
            {
                Console.WriteLine($"Unable to locate {arg2.Name} at {path}", e);
            }
            
            return null;
        }
    }

Logs

Environment

  • SDK Version: AWSSDK.S3 3.3.111.23
  • Package Version:AWSSDK.S3 3.3.111.23
  • OS Info: Windows 10
  • Build Environment Terminal dotnet
  • Targeted .NET Platform: .NET Core 3.1

Resolution

  • 👋 I can/would-like-to implement a fix for this problem myself

This is a 🐛 bug-report

@madhub madhub added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Apr 29, 2021
@ashishdhingra ashishdhingra added module/sdk-core B perf low-effort and removed needs-triage This issue or PR still needs to be triaged. labels Apr 29, 2021
@github-actions
Copy link

github-actions bot commented May 1, 2022

We have noticed this issue has not received attention in 1 year. We will close this issue for now. If you think this is in error, please feel free to comment and reopen the issue.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label May 1, 2022
@madhub
Copy link
Contributor Author

madhub commented May 3, 2022

Any update on this issue, This needs to be fixed.

@ashovlin ashovlin removed the closing-soon This issue will automatically close in 4 days unless further comments are made. label May 3, 2022
@ashishdhingra ashishdhingra added p2 This is a standard priority issue queued and removed B labels Nov 2, 2022
@ashishdhingra ashishdhingra added xs Effort estimation: tiny and removed low-effort labels Apr 19, 2023
@normj
Copy link
Member

normj commented Mar 5, 2025

The internal reflection for log4net has been removed in the upcoming V4 of the SDK. In V4 connecting the SDK's logging to a logging framework is done by including an adaptor package. Check out the logging section in the V4 tracker issue. #3362

@normj normj closed this as completed Mar 5, 2025
Copy link

github-actions bot commented Mar 5, 2025

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. module/sdk-core p2 This is a standard priority issue perf queued xs Effort estimation: tiny
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants