public static void OpenSysLog(SysLog.Facility facility, string applicationName, string serverAddr, int serverPort = 514, bool useRfc5424 = false) { try { syslogFacility = facility; syslogMachineName = Environment.MachineName; if (String.IsNullOrEmpty(applicationName)) { syslogApplicationName = System.AppDomain.CurrentDomain.FriendlyName; } else { syslogApplicationName = applicationName; } syslogApplicationName += String.Format("[{0}]", Process.GetCurrentProcess().Id); if (useRfc5424) { syslogSerializer = new SyslogRfc5424MessageSerializer(); } else { syslogSerializer = new SyslogRfc3164MessageSerializer(); } syslogSender = new SyslogUdpSender(serverAddr, serverPort); } catch (Exception e) { syslogSender = null; syslogSerializer = null; Log(Level.Warning, String.Format("Failed to create Syslog sender ({0})", e.Message)); } }
public static void OpenSysLog(SysLog.Facility facility, string ServerAddr, int ServerPort = 514, bool useRfc5424 = false) { OpenSysLog(facility, null, ServerAddr, ServerPort, useRfc5424); }
public static void OpenSysLog(SysLog.Facility facility, string applicationName, string ServerAddr, int ServerPort = 514, bool useRfc5424 = false) { try { syslogFacility = facility; syslogMachineName = Environment.MachineName; if (String.IsNullOrEmpty(applicationName)) syslogApplicationName = System.AppDomain.CurrentDomain.FriendlyName; else syslogApplicationName = applicationName; syslogApplicationName += String.Format("[{0}]", Process.GetCurrentProcess().Id); if (useRfc5424) syslogSerializer = new SyslogRfc5424MessageSerializer(); else syslogSerializer = new SyslogRfc3164MessageSerializer(); syslogSender = new SyslogUdpSender(ServerAddr, ServerPort); } catch { } }
protected static int CalculatePriorityValue(SysLog.Facility facility, SysLog.Severity severity) { return(((int)facility * 8) + (int)severity); }