using System; using System.Collections.Generic; using System.Configuration; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Factory.FactoryMethod { abstract class LogFactory { // factory method 패턴 protected abstract ILog GetLog(); public void Log(string message) { ILog logger = GetLog(); // 어떤 로그타입을 사용할 지 결정되지 않음 logger.write($"{DateTime.Now}: {message}"); } public static LogFactory GetLogger() { string logType = ConfigurationManager.AppSettings["LogType"]; switch (logType) { case "DB": return new DbLogFactory(); case "XML": return new XmlLogFactory(); default: throw new ApplicationException(); } } } }