<div dir="ltr"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-im" style="color:rgb(80,0,80)">> We plan to implement something similar to rotate count<br></span>> <<a href="https://linux.die.net/man/8/logrotate" rel="noreferrer" target="_blank">https://linux.die.net/man/8/logrotate</a>> in linux logrotate. It is basically<br><span class="gmail-im" style="color:rgb(80,0,80)">> like a ring buffer in the file system. We keep N log files. The latest log<br></span><span class="gmail-im" style="color:rgb(80,0,80)">> file is in plain text and the writer keeps appending data to it. The rest<br></span><span class="gmail-im" style="color:rgb(80,0,80)">> N-1 files are compressed.</span><span class="gmail-im" style="color:rgb(80,0,80)"><br></span>In this case, you will keep full logs without gaps:<br>```<br>Host start <- log is empty, start logging<br>|<br>[...] <- write file, compress and rotate file<br>|<br>Host reboot or shut down<br>```<br>If there are too many logs, logrotate removes the oldest one and we lose the<br>boot log (form host start).<br>This is the default Hostlogger mode:<br>```<br>Host start <- log is empty, start logging<br>|<br>[line 3000] <- flush 3000 lines to the persistent file<br>|<br>[...] <- these logs are skipped (the last 3000 lines are in memory)<br>|<br>Host reboot or shut down <- flush last 3000 lines to the file</blockquote><div><br></div><div>Thanks for your explanation, but I didn't get it. Are you arguing that one can keep more logs in memory rather than on disk? If there are too many logs in a boot cycle, won't the current hostlogger lose some earlier logs (boot logs) as well? Or did me missing something?</div><div><br></div><div>Also, we already talked about it: there's a problem that if BMC loses the power before it sends out a signal to hostlogger, data in memory won't be persisted.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, May 26, 2021 at 9:08 AM Artem Senichev <<a href="mailto:artemsen@gmail.com">artemsen@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Wed, May 26, 2021 at 08:17:11AM -0700, Nan Zhou wrote:<br>
> ><br>
> > > > > 3. zlib_file.xpp, zlib_exception.xpp:<br>
> > > > > will be removed or slightly changed; we can potentially use the linux<br>
> > > > > logrotate which has built-in compression and file rotation (in this<br>
> > case<br>
> > > > > these compression utilities will be removed).<br>
> > > > > The latest log file isn't compressed any more. History log files are<br>
> > > > > still compressed.<br>
> > > > Just curious, how are you going to remove the oldest messages from the<br>
> > > > latest file in runtime? You are not going to rewrite the entire file on<br>
> > > > every input character, are you?<br>
> > ><br>
> > > The following is my current idea: we will rename the latest file to<br>
> > > something else and notify the writer (hostlogger) to close its old file<br>
> > > descriptor and open a new one (should be doable via linux logrotate and<br>
> > > inotify or some signal handlers, as logrotate is able to send some<br>
> > signals<br>
> > > to hostlogger if a rotation is performed). The writer keeps appending<br>
> > logs<br>
> > > most of the time using the same fd unless the latest file is rotated.<br>
> > This<br>
> > > should be better than truncating the file where the reader (BMCWeb) won't<br>
> > > have race conditions (it might read old snapshots but it is not a big<br>
> > deal<br>
> > > in our case).<br>
> > Currently we can keep the last N lines of the host's output, the oldest<br>
> > messages are removed. It is easy to implement with a buffer in memory.<br>
> > But how are you going to get rid of the old lines if you write data<br>
> > directly<br>
> > to the log file?<br>
> > Rotation will not help you with that (we actually don't need to store such<br>
> > old<br>
> > logs).<br>
> <br>
> We plan to implement something similar to rotate count<br>
> <<a href="https://linux.die.net/man/8/logrotate" rel="noreferrer" target="_blank">https://linux.die.net/man/8/logrotate</a>> in linux logrotate. It is basically<br>
> like a ring buffer in the file system. We keep N log files. The latest log<br>
> file is in plain text and the writer keeps appending data to it. The rest<br>
> N-1 files are compressed.<br>
<br>
In this case, you will keep full logs without gaps:<br>
```<br>
Host start <- log is empty, start logging<br>
|<br>
[...] <- write file, compress and rotate file<br>
|<br>
Host reboot or shut down<br>
```<br>
<br>
If there are too many logs, logrotate removes the oldest one and we lose the<br>
boot log (form host start).<br>
<br>
This is the default Hostlogger mode:<br>
```<br>
Host start <- log is empty, start logging<br>
|<br>
[line 3000] <- flush 3000 lines to the persistent file<br>
|<br>
[...] <- these logs are skipped (the last 3000 lines are in memory)<br>
|<br>
Host reboot or shut down <- flush last 3000 lines to the file<br>
```<br>
<br>
-- <br>
Regards,<br>
Artem Senichev<br>
Software Engineer, YADRO.<br>
</blockquote></div>