private static ILogger GetLogger() { switch (ConsoleUtility.Option("Which Logger would you like to use?", Generic, LogglySyslog, LogglyHttp, "Quit")) { case Generic: var genOptions = new Options { HostNameOrIp = ConsoleUtility.Question("What is the Host Name or IP of your Syslog Server?"), Port = ConsoleUtility.Question <int>("What is the port your Syslog Server is listening on?"), AppNameOrTag = "LoggingDemo" }; return(new SyslogLogger(genOptions)); case LogglySyslog: return(new LogglySyslogLogger(GetLogglyOptions())); case LogglyHttp: return(new LogglyHttpLogger(GetLogglyOptions())); case "Quit": break; default: Console.WriteLine("You selected a bad option"); break; } Continue = false; return(null); }
static void Main(string[] args) { var logger = GetLogger(); while (Continue) { Console.Clear(); string message = ConsoleUtility.Question("Enter a test message, or type 'quit' to exit:"); if (message.Equals("quit", StringComparison.OrdinalIgnoreCase)) { break; } logger.Log(message, Category.Debug, Priority.None); } Console.WriteLine("Thanks for logging"); }
private static ILogglyOptions GetLogglyOptions() => new LogglyOptions { AppName = "LoggingDemo", Token = ConsoleUtility.Question("What is your Loggly Token?") };