You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
748 B

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();
}
}
}
}