protected override void Shutdown() { lock (syncRoot) { if (writer != null) { try { if (log == null || log is NullLogger) { log = LogManager.Instance.GetProvider(typeof(FlatFileLogFactory)); } log.Log(0, "Shutdown: Flushing and closing log"); writer.Flush(); writer.Dispose(); try { writer.Dispose(); } catch { } writer = null; } catch { log.Log(1000, "Shutdown: Failed flushing and closing log"); } } } }
private static void Log(string method, LogLevel level, string message) { if (logger == null) { logger = LogManager.Instance.GetProvider(typeof(OncorServer)); } if (logger != null) { logger.Log(method, LogLevel.Info, message); } }
public void Start() { if (this.State == RunState.Stopped || this.State == RunState.Initialized) { LogProviderBase pp = LogManager.Instance.GetProvider(typeof(OncorHostShim)); pp.Log(0, "Start: " + svr.State.ToString()); if (svr.Start()) { this.State = RunState.Running; } else { this.State = RunState.FailedStarting; } } }
public void Initialize() { if (this.State == RunState.Created || this.State == RunState.FailedInitializing) { this.State = RunState.Initializing; LogProviderBase pp = LogManager.Instance.GetProvider(typeof(OncorHostShim)); pp.Log(0, "Init: " + svr.State.ToString()); if (svr.Init()) { this.State = RunState.Initialized; } else { this.State = RunState.FailedInitializing; } } }
static void Main(string[] args) { ConfigurationManager.Instance.Bootstrap(); ConfigurationManager.Instance.Initialize(); ConfigurationManager.Instance.Start(); LogManager.Instance.Bootstrap(); LogManager.Instance.Initialize(); LogManager.Instance.Start(); if (LogManager.Instance.State == Osrs.Runtime.RunState.Running) { LogProviderBase prov = LogManager.Instance.GetProvider(typeof(Program)); if (prov != null) { prov.Log("Hi there", LogLevel.Info); } } }