1technophile / OpenMQTTGateway

MQTT gateway for ESP8266 or ESP32 with bidirectional 433mhz/315mhz/868mhz, Infrared communications, BLE, Bluetooth, beacons detection, mi flora, mi jia, LYWSD02, LYWSD03MMC, Mi Scale, TPMS, BBQ thermometer compatibility & LoRa.
https://docs.openmqttgateway.com
GNU General Public License v3.0
3.5k stars 775 forks source link

Feature syslog option #734

Open michapr opened 3 years ago

michapr commented 3 years ago

What do you think about the option to add the syslog.h to the project?

In such a case you could debug the device if it is not more connected via serial. Updating via OTA is working fine - a log via network could be helpful.

I have added it in most of my projects and think it is useful.

Thanks! Michael

1technophile commented 3 years ago

You mean this library? https://github.com/arcao/Syslog

michapr commented 3 years ago

yes, this one. sorry,... forgot the link ;)

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

michapr commented 3 years ago

I really still think it would be a good idea to have this syslog feature. If enabled then send the same information additional to syslog server with same level.

In this time I add it after every update the needed output lines... But I think it can be done by a new function, maybe.

Thanks

DavidStacer commented 3 years ago

In many of my projects, I've been using a ESP-01 (ESP8266) with some code to send Syslog messages. Connected the TX pin on the ESP32 to the RX of the ESP-01. ESP-01's job is only to send any and all text it receives over the serial port from the ESP32 to a syslog server.

michapr commented 3 years ago

It's not big deal to add it (technical) - it is working, if define extra places with extra lines (code) for syslog output. (I use it in my BLE gateways)

But I had no idea how to solve it "elegantly" with a function, so that syslog can use the same procedure as standard logging.

1technophile commented 3 years ago

But I had no idea how to solve it "elegantly" with a function, so that syslog can use the same procedure as standard logging.

Should maybe implemented at ArduinoLog level ?

Nikolay-Ch commented 2 years ago

This feature is very useful to collect all logs in one place

h2zero commented 2 years ago

A similar idea that could be used more directly with arduinolog would be a telnet server. This is what I use to monitor the logs of my devices when not connected with serial port.

Nikolay-Ch commented 2 years ago

A similar idea that could be used more directly with arduinolog would be a telnet server. This is what I use to monitor the logs of my devices when not connected with serial port.

Hm.... In my own network, I use FluentD to collect all logs (from switches, firewalls, and other devices) in one location... So, it is useful to use one service to collect all logs... And also SysLog format is standard, so it can be used with different log-collectors in different OSs (windows, linux etc)...

tablatronix commented 2 years ago

I also want syslog capability, I use syslogging for all my iot devices, tasmota has it build in, and I add it to all my projects. I have not looked at tasmotas impelmentation, but I use streamutils and arcao/Syslog.

Is there any way to make plugins for this, or any existing logging mechanism to hook into ? I will take a look and see if there is an easy way to code it in, or a PR to expose existing logging.

If not I can insert streamutils and redirect the serial stream if its harcoded.

EDIT: oops I misunderstood, that arduinolog is the existing implementation, that makes it easier I think, should be able to just add syslog and add a log stream variable in user_config to replace &serial in main.ino

michapr commented 1 year ago

any progress here? Would be really nice to have this option to check the configured messages wireless on syslog server...

ssalonen commented 4 months ago

This would be useful to notice any errors and such

Did someone have code based on ArduinoLog?

EDIT: WebSerial in this project implementation should serve as good basis for syslog ArduinoLog output as well

ssalonen commented 4 months ago

Further comment

I found this library https://github.com/dirkx/tee-log that would make the implementation rather straightforward

It basically implements the Print interface, and therefore is pluggable with ArduinoLog used by openmqttgateway.

Tee-log logs to both syslog and optionally also to serial. Only caveat seems to be the fact that it is hardcoded to use wireless network interface (WifiUdp)...probably not a large effort to upstream/fork ethernet support

Integration would then basically consist of introducing configuration parameters for the

  1. syslog destination ip and port config parameters. Syslog identifier could be the hostname of the device
  2. Flag to enable/disable syslogging functionality. If enabled, instead logging to Serial, we would use SyslogStream from tee-log instead.

@tablatronix did you work on this already or plan to work on it?

tablatronix commented 4 months ago

I have an implementation I use in my own libs that works. I use a redirector similar to tee and a syslog library. I can see if I can bring it over in a fork or plugin

tablatronix commented 4 months ago

I am using

/**
 * Local logging solutions, using steamutils and syslog
 * StreamUtils
 * https://github.com/Chris--A/PrintEx
 * Allows for stream buffering, redirection, mirroring etc.
 *
 * syslog
 * https://github.com/arcao/Syslog.git
 * An Arduino library for logging to Syslog server via `UDP` protocol in 
 * [IETF (RFC 5424)] and [BSD (RFC 3164)] message format
 */

I really need to see what tasmota is using, they probably rolled their own minimal version that might be better suited.