Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
35 lines (32 sloc) 1.07 KB
using System.Linq;
using Autofac;
using Autofac.Core;
using log4net;
using Microsoft.Azure.WebJobs.Host;
namespace AzureFunctionsLogging.Log4net
{
/// <summary>
/// Constructs the TraceWriterLogger by passing in the type of the calling
/// class and the resolved TraceWriter instance
/// </summary>
///
/// <inheritdoc />
public class TraceWriterLoggingModule : Module
{
protected override void AttachToComponentRegistration(
IComponentRegistry componentRegistry,
IComponentRegistration registration
) => registration.Preparing += OnComponentPreparing;
private void OnComponentPreparing(object sender, PreparingEventArgs e)
{
e.Parameters = e.Parameters.Union(
new[]
{
new ResolvedParameter(
(p, i) => p.ParameterType == typeof(ILog),
(p, i) => new ILogTraceWriterAdapter(p.Member.DeclaringType, e.Context.Resolve<TraceWriter>())
),
});
}
}
}
You can’t perform that action at this time.