So the way I usually do it (with DI) is to add the extension to my container:
unityContainer.AddNewExtension<Log4NetExtension>();
and then at the constructor of the class where I need to call the logger I use something like this:
public class test
{
private ILog logger;
public test (ILog logger)
{
this.logger =logger;
}
}
Now my problem is, in one of my classes, I don't want to pass anything to the constructor and I was wondering how can I assign my logger (since im using unity I thought of calling resolve but it's not working)
public class test
{
private ILog logger;
public test()
{
logger = unityContainer.Resolve<ILog>(); //I edited this for simplicity
}
}
Error is something like the container didn't know how to resolve ILog.
EDIT:
The class that didn't let me pass anything through its constructor is a Job (implements IJob) class, in the end I ended up using a job listener instead of logging in each job.
Some tips if you still want to pass something for the constructor is by implementation a Job Factory which should help you inject parameters. And I saw a nuget you can add to help you with Quartz integration with Unity.