Ubuntu: Send JSON data with logger command



Question:

I am trying to use (Ubuntu) logger command to send data to Logstash. I want the data to contain JSON structured data, like:

logger -p syslog.warn "{"user":"admin", "password":"admin"}}"  

I remember once I read something about @eee somewhere but I can't found that page again, kind of:

logger -p syslog.warn @eee"{"user":"admin", "password":"admin"}}  

How can I send JSON data with logger command?


Solution:1

I'm not sure about the eee stuff, but you just need to change your command a little bit (escaping the quotation marks):

logger -p syslog.warn {\"user\":\"admin\", \"password\":\"admin\"}

Meanwhile, run tailf to watch the syslog

$ tailf /var/log/syslog  Jan 12 18:25:48 laptop ubuntu: {"user":"admin", "password":"admin"}  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »