summaryrefslogtreecommitdiff
path: root/slips/src/app/Marina/Infrastructure/Logging/Log4Net/Log4NetLogFactory.cs
blob: 996557f445bfc732a4c16d1960de68bb50820069 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using System;
using log4net;
using Marina.Infrastructure.Logging.Interfaces;
using ILog=Marina.Infrastructure.Logging.Interfaces.ILog;

namespace Marina.Infrastructure.Logging.Log4Net {
	public class Log4NetLogFactory : ILogFactory {
		private ILog4NetInitializationCommand initializationCommand;
		private bool initialized;

		public Log4NetLogFactory( ) : this( new Log4NetInitializationCommand( ) ) {}

		public Log4NetLogFactory( ILog4NetInitializationCommand initializationCommand ) {
			this.initializationCommand = initializationCommand;
		}

		public ILog CreateFor( Type typeThatRequiresLoggingServices ) {
			WireUpConfiguration( );
			return new Log4NetLog( LogManager.GetLogger( typeThatRequiresLoggingServices ) );
		}

		private void WireUpConfiguration( ) {
			if ( initialized ) {
				return;
			}
			initialized = true;
			initializationCommand.Execute( );
		}
	}
}