Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7903189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:41:07+00:00 2026-06-03T09:41:07+00:00

I came across a weird issue when using JVM garbage collection log option with

  • 0

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.

Let say this is the java call (Test.class is located in /home/test/) :

java -Xloggc:/home/test/test.log -cp /home/test/ Test

The configuration of logrotate for this file is as follow :

/home/test/test.log {
   rotate 56
   missingok
   notifempty
   copytruncate
   nocreate
   nomail
}

I also have a crontab entry logging every minute for testing purposes :

*/1 * * * * /usr/sbin/logrotate -f /etc/logrotate.d/gcLog

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).

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:

java -verbose:gc -cp /home/test/ Test > /home/test/test.log

Once again, when test.log is truncated by logrotate, the new created file is filled with NUL (^@) values on the first line.

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.

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)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T09:41:09+00:00Added an answer on June 3, 2026 at 9:41 am

    We had the same problem at our place running Jboss7 and Java6, we were getting NULLs in the GC file and they just kept growing.

    Solution was to just log GC to stdout and then append stdout to a file:

    Simple example:

    java -verbose:gc >> console.log
    

    Apparently using append (>>) gets rid of the Java “pointer” to a position in the file. With the added bonus of not having the GC logs reset per server restart so we can have some stats over time.

    At least the IBM PMAT tool has no problem parsing the sysout with GC output.

    The simplest solution is sometimes the best 🙂

    Though I wish Java would support rotating of GC logs, as I see someone’s been discussing before:
    http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2011-April/002061.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I came across this weird C++ program. #include <iostream> using namespace std; int main()
I came across a very weird issue where in my querystirng had ++ as
I'm building a Backbone app and I came across this weird issue. In the
I came across something weird today, and I was wondering if any of you
I just came across this weird problem that is happening in IE. In the
I accidentally came across this weird but valid syntax i=3 print i+++i #outputs 6
I tried modifying a Yesod project, and came across a weird error. First I
I recently came across some weird looking class that had three constructors: class Class
I am cleaning my Perl code for production release and came across a weird
Possible Duplicate: Weird use of void I was reading C code and came across

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.