Skip to content
Advertisement

How to remove/modify syslogd message’s header?

I’m currently use the syslogd of busybox for logging some information. However, I’m unable to modify the message’s header. I log the message like this:

syslog(LOG_INFO,"My messagen");

And I got this output:

Jul  4 15:00:11 halo user.info syslog: My message

I want to replace message’s header with epoch time format like this:

1529293692,My message

Or is there any way to completely remove the message’s header so I could manually add the epoch time in code?

Advertisement

Answer

I have done the research around and found that it is impossible to modify the output message log of syslogd with supported configuration. So I dig into the busybox’s source code and modify it. If you face the same issue, you could find it at function:

static void timestamp_and_log(int pri, char *msg, int len)

I check the pri variable to see which level log is it and change the actual outcome message, which is msg.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement