I have a Syslog Server (receive log event and store in file) working in 514 port. The syslog server is operating good, becase was tested with Router, configuring the router with IP of Syslog Server and Port, and Router Sent Log to Syslog Server.
But, Now I want to make a application that replace the router (when send event/log to server).
I have this:
Logger mylogger;
mylogger = Logger.getLogger(this.getClass().getName());
SocketHandler myhandler = null;
try {
myhandler = new SocketHandler("localhost", 514); //With Port 80 Work!
myhandler.setLevel(Level.FINEST);
mylogger.setLevel(Level.CONFIG);
mylogger.addHandler (myhandler);
mylogger.log(Level.SEVERE, "SEVERE LOG...");
mylogger.log(Level.WARNING, "WARNING LOG...");
mylogger.log(Level.INFO, "INFO LOG...");
mylogger.log(Level.CONFIG, "CONFIG LOG...");
mylogger.log(Level.FINE, "FINE LOG...");
mylogger.log(Level.FINER, "FINER LOG...");
mylogger.log(Level.FINEST, "FINEST LOG...");
myhandler.close();
}
catch (IllegalArgumentException e) { System.out.println("IllegalArgumentException:"+e.toString()); }
catch (IOException e) { System.out.println("IOException:"+e.toString()); }
catch (SecurityException e) { System.out.println("SecurityException0:"+e.toString()); }
I have this message:
IOException:java.net.ConnectException: Connection refused: connect
and the problem is with Socket Handler in 514 Port.
I need replace the "localhost" by my real IP of Syslog Server and port What Can I do?
Please help me.
Best Regards,
Bernal