Note that there are some explanatory texts on larger screens.

plurals
  1. POGarbage collector log (loggc) file rotation with logrotate does not work properly
    primarykey
    data
    text
    <p>I came across a weird issue when using JVM garbage collection log option with Linux logrotate command. When rotation is executed, it fills NUL ( ^@ ) values the first line of the file given as argument to the JVM.</p> <p>Let say this is the java call (Test.class is located in /home/test/) :</p> <blockquote> <p>java -Xloggc:/home/test/test.log -cp /home/test/ Test</p> </blockquote> <p>The configuration of logrotate for this file is as follow :</p> <blockquote> <p>/home/test/test.log {<br /> &nbsp;&nbsp;&nbsp;rotate 56<br /> &nbsp;&nbsp;&nbsp;missingok<br /> &nbsp;&nbsp;&nbsp;notifempty<br /> &nbsp;&nbsp;&nbsp;copytruncate<br /> &nbsp;&nbsp;&nbsp;nocreate<br /> &nbsp;&nbsp;&nbsp;nomail<br /> }</p> </blockquote> <p>I also have a crontab entry logging every minute for testing purposes :</p> <blockquote> <p>*/1 * * * * /usr/sbin/logrotate -f /etc/logrotate.d/gcLog</p> </blockquote> <p>I came to the conclusion that JVM writes in append mode and keeps some kind of offset used to write next line in the related file, even if the file is truncated by logrotate (I may be wrong).<br/><br/><br/></p> <p>My next idea was to try and redirect the stdout to test.log file. I used this java call and kept the same configuration for logrotate and cron:</p> <blockquote> <p>java -verbose:gc -cp /home/test/ Test > /home/test/test.log</p> </blockquote> <p>Once again, when test.log is truncated by logrotate, the new created file is filled with NUL (^@) values on the first line.<br/><br/><br/></p> <p>No need to say that I didn't find anything helpful using google. I found another question on stackoverflow kind of related, but I couldn't manage to setup Java Script Wrapper, so this doesn't work.</p> <p>Did anybody come across this issue ? Any idea why is this happening ? Better, any workaround or solution ? I need to try and pipe the call to the application to a some script reading the output and maybe look at the way Tomcat logs and rotate stdout in catalina.out (here some help will be really appreciated as well)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload