Giter VIP home page Giter VIP logo

simple-syslog-server's Introduction

Simple Syslog Server

All-in-one implementation of RFC-5424 Syslog Protocol for testing purposes.

The server is based on syslog4j library.

There are 3 implemented server configurations:

  • UDP
  • TCP
  • TLS (uses self-signed certificate)

The syslog server listens on port 9898 in all configurations.

Usage

java -jar simple-syslog-server.jar [udp|tcp|tls]

If no argument is provided, then the "tls" configuration is started.

Output

Console then contain output similar to:

Simple syslog server (RFC-5424)
Usage:
  java -jar simple-syslog-server.jar [protocol]

Possible protocols: udp, tcp, tls

No protocol provided. Defaulting to tls
Starting Simple Syslog Server
Protocol:     tls
Bind address: 0.0.0.0
Port:         9898
Creating Syslog server socket
Handling Syslog client /10.40.4.198
>>> Syslog message came: Rfc5424SyslogEvent [prioVersion=<12>1, facility=1, level=4, version=1, timestamp=2014-010-22T12:15:48.952+02:00, host=my-nb, appName=Test, procId=11119, msgId=-, structuredData=-, message=Message one]
>>> Syslog message came: Rfc5424SyslogEvent [prioVersion=<12>1, facility=1, level=4, version=1, timestamp=2014-010-22T12:15:52.039+02:00, host=my-nb, appName=Test, procId=11119, msgId=-, structuredData=-, message=Message two]

Testing

The format of Syslog messages is specified by the RFC-5424

To test the syslog server, you can either use the logger Linux command:

logger --tcp -n localhost -P 9898 "Test message"

or try directly one of example messages specified in the RFC:

nc -w0 localhost 9898 <<< "<34>1 2003-10-11T22:14:15.003Z mymachine.example.com su - ID47 - BOM'su root' failed for lonvick on /dev/pts/8"

License

simple-syslog-server's People

Contributors

dependabot[bot] avatar kwart avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

simple-syslog-server's Issues

Syslog4j dependency question

Hey @kwart

First of all I would like to thank you. This project has helped me understand how syslog4j library works and save me a ton of time.

This is not actually an issue, it's rather a background question. I've been reseaching about "org.syslog4j" because the last published version was 10 years ago. Do you know whether is any other recent version or any other library trustworthy to handle syslog servers in java? I've found a lot of repos which contain the original sylog4j source code patched (fixing minor issues) but even these have been many years unmanteined.

Thanks for your time

rsyslog.conf

I'm studying your project recently. But I have some problems.

When using the TLS protocol, it prompted me some errors. I realized I needed to configure rsyslog. conf. Could you show me this file what you configured?

Thanks

javax.net.ssl.SSLException: Unsupported or unrecognized SSL message

I have two machines on the same home LAN. Machine 1 has IP of 192.168.0.12 and Machine 2 has an IP of 192.168.0.14.

On Machine 2 (the syslog server running this project) I build the project via mvn package and then run it out of the target directory via java -jar simple-syslog-server.jar tls. Then back on Machine 1 (the syslog "client") I run:

nc -w0 192.168.0.14 9898 <<< "<34>1 2003-10-11T22:14:15.003Z mymachine.example.com su - ID47 - BOM'su root' failed for lonvick on /dev/pts/8"

Back on Machine 2 I get SSL-related errors. Here is the exact console output from Machine 2:

java -jar simple-syslog-server.jar tls
Simple syslog server (RFC-5424)
Usage:
  java -jar simple-syslog-server.jar [protocol]

Possible protocols: udp, tcp, tls

Starting Simple Syslog Server

Protocol:     tls
Bind address: 0.0.0.0
Port:         9898
Creating Syslog server socket


Handling Syslog client /192.168.0.12
javax.net.ssl.SSLException: Unsupported or unrecognized SSL message
  at java.base/sun.security.ssl.SSLSocketInputRecord.handleUnknownRecord(SSLSocketInputRecord.java:451)
  at java.base/sun.security.ssl.SSLSocketInputRecord.decode(SSLSocketInputRecord.java:175)
  at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:110)
  at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1418)
  at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1324)
  at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:440)
  at java.base/sun.security.ssl.SSLSocketImpl.ensureNegotiated(SSLSocketImpl.java:829)
  at java.base/sun.security.ssl.SSLSocketImpl$AppInputStream.read(SSLSocketImpl.java:920)
  at java.base/java.io.BufferedInputStream.fill(BufferedInputStream.java:252)
  at java.base/java.io.BufferedInputStream.read(BufferedInputStream.java:271)
  at com.github.kwart.syslog.TCPSyslogSocketHandler.run(TCPSyslogSocketHandler.java:89)
  at java.base/java.lang.Thread.run(Thread.java:836)

Do I need to change the message format for TLS?

StringIndexOutOfBoundsException on TCP connection

Hi I'm trying to get this tool working on my home network. On Laptop 1 (the "syslog server") I clone this project, run mvn package, and then from inside the target directory, I run:

java -jar simple-syslog-server.jar tcp

The syslog server starts up (!!!) and I see:

Simple syslog server (RFC-5424)
Usage:
  java -jar simple-syslog-server.jar [protocol]

Possible protocols: udp, tcp, tls

Starting Simple Syslog Server
Protocol:     tcp
Bind address: 0.0.0.0
Port:         9898
Creating Syslog server socket

From Laptop 2 I run:

nc -w0 <laptop1.ip> 9898 <<< "testing again from my home machine"

Where, obviously, <laptop1.ip> is Laptop 1's local IP address on the home network. As soon as I run that command, from Laptop 1, I see:

Handling Syslog client /<laptop2.ip>
Exception in thread "Thread-4" java.lang.StringIndexOutOfBoundsException
  at java.base/java.lang.String.<init>(String.java:615)
  at com.github.kwart.syslog.Rfc5424SyslogEvent.getString(Rfc5424SyslogEvent.java:116)
  at com.github.kwart.syslog.Rfc5424SyslogEvent.<init>(Rfc5424SyslogEvent.java:65)
  at com.github.kwart.syslog.TCPSyslogSocketHandler.handleSyslogMessage(TCPSyslogSocketHandler.java:100)
  at com.github.kwart.syslog.TCPSyslogSocketHandler.run(TCPSyslogSocketHandler.java:75)
  at java.base/java.lang.Thread.run(Thread.java:836)

Am I doing anything wrong here? Is that not a valid syslog message? If its is, how can I troubleshoot this some more? Thanks in advance!

Error 502

Hello,

When I try to deploy JAR file to Pivotal Cloud Foundry, I had some problems with conf (set TCP as default and change the port number to 8080) but I solved that. So, now I get 502 in log and I cannot resolve why this happened?

There are modified logs:

2020-05-19T14:54:39.184+08:00 [CELL/0] [OUT] Container became healthy 2020-05-19T14:54:39.515+08:00 [APP/PROC/WEB/0] [OUT] Handling Syslog client /10.1.1.10 2020-05-19T14:54:48.574+08:00 [RTR/3] [OUT] java-syslog-service.myurl.com - [2020-05-19T12:54:45.571+0000] "OPTIONS /cloudfoundryapplication HTTP/1.1" 502 0 67 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36" "55.66.77.88:2206" "10.1.1.10:61001" x_forwarded_for:"11.22.33.44, 55.66.77.88" x_forwarded_proto:"https" vcap_request_id:"123" response_time:2.002447003 app_id:"123" app_index:"0" x_b3_traceid:"123" x_b3_spanid:"123" x_b3_parentspanid:"-" b3:"123-123"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.