Closed
Description
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