private Logger() { var fileName = ConfigurationManager.AppSettings["LogFile"].ToString(); _logProviders = new List<ILogProvider>(); _logProviders.Add(new FileLogProvider(fileName)); _logProviders.Add(new DatabaseLogProvider()); _logProviders.Add(new ConsoleLogProvider()); DefaultStrategy = LogStrategy.All; Strategy = DefaultStrategy; }
static void Main(string[] args) { if (args.Length != 1) { return; } LogStrategy lf = LoggerFactory.CreateLogger("FILE"); Table(lf); Console.ReadKey(); }
/// <summary> /// Initializes the <see cref="Skahal.Logging.SHLog"/> class. /// </summary> static SHLog() { if (SHDebug.IsDebugBuild) { LogStrategy = new SHDebugLogStrategy(); } else { LogStrategy = new SHReleaseLogStrategy(); } Debug("SHLog: log strategy: {0}", LogStrategy.GetType()); }
private static bool Table(LogStrategy ls) { int a = 10; int b = 1; while (b < 3) { ls.Log("Table", a.ToString() + " * " + b.ToString(), "=" + (a * b).ToString()); b++; } return(true); }
/// <summary> /// Instantiates a logger. /// </summary> /// <param name="logStrategy"> /// The logging strategy. Available: /// <para>Console</para> /// <para>Windows Event Log</para> /// </param> public ServiceLogger(LogStrategy logStrategy) { switch (logStrategy) { case LogStrategy.Console: this.strategy = new ConsoleLogStrategy(); break; case LogStrategy.WindowsEventLog: this.strategy = new WindowsEventLogStrategy(); break; default: this.strategy = new WindowsEventLogStrategy(); break; } }
/// <summary> /// Logs a given event. A logging strategy can be chosen. /// </summary> /// <param name="serviceEvent">The service event.</param> /// <param name="logStrategy">The strategy to be used</param> /// <param name="message">The message to pass along.</param> public static void LogEvent(ServiceEvent serviceEvent, LogStrategy logStrategy, string message = null) { ILogStrategy loggingStrategy; switch (logStrategy) { case LogStrategy.Console: loggingStrategy = new ConsoleLogStrategy(); break; case LogStrategy.WindowsEventLog: loggingStrategy = new WindowsEventLogStrategy(); break; default: loggingStrategy = new WindowsEventLogStrategy(); break; } loggingStrategy.LogEvent(serviceEvent, message); }
public static Logger LoggerFactory(string name, LogStrategy strategy = LogStrategy.STATIC) { ILogStrategy _strategy; switch (strategy) { case LogStrategy.STATIC: _strategy = new StaticStrategy(); break; case LogStrategy.HTTP_API: _strategy = new APIStrategy(); break; case LogStrategy.FILE: _strategy = new FileStrategy(); break; default: throw new Exception("Invalid Log Strategy!!"); break; } return(new Logger(name, _strategy)); }
public T GetSyncPayloadLogProvider <T>(SyncConfig config, LogStrategy logStrategy) => GetProvivder <T>(config.Providers.Sync.PayloadLog, logStrategy.PayloadLogProvider);