-Xss256k
-Djava.net.preferIPv4Stack=true
-Dfile.encoding=UTF-8
-XX:+UseParNewGC
-XX:+UseConcMarkSweepGC
-XX:CMSInitiatingOccupancyFraction=75
-XX:+UseCMSInitiatingOccupancyOnly
-XX:+DisableExplicitGC
-XX:+PrintGCDetails
-XX:+PrintGCDateStamps
-XX:+PrintGCTimeStamps
-XX:+PrintClassHistogram
-XX:+PrintClassHistogramBeforeFullGC
-XX:+PrintTenuringDistribution
-XX:+PrintGCApplicationStoppedTime
-XX:+PrintPromotionFailure
-XX:PrintFLSStatistics=1
-verbose:gc
-XX:GCLogFileSize=64m
-XX:NumberOfGCLogFiles=2
-XX:+UseGCLogFileRotation
-Xloggc:./logs/gc.log
The above are the complete list of JAVA_OPTS I'm passing for my application. The problem is that gc.log file is not being created sometimes if the logs directory doesn't exist by the time application starts. But gc.log is created always if I make sure that the logs directory exists by the time application starts.
So am I right in assuming that before my log4j framework creates the logs directory if a GC occurs, Xloggc will fail safely? Is there any other workaround other than pre-creating the logs directory manually?