1

I hava jar with class my.package.Foo inside, containing main method.

What is more i have Log4j configurated as a logging system.

I want to print full stack trace while exception is catched, however i read this topic: log4j not printing the stacktrace for exceptions and i think that i need to use a -XX:-OmitStackTraceInFastThrow flag.

So i'm trying to call my app with command line like this:

java -XX:-OmitStackTraceInFastThrow -cp %JAR_LOCATION:% my.package.Foo

However i'm still missing stacktrace, i get only short exception message.

Here is my log4j config:

log4j.rootLogger=INFO, CONSOLE, FILE
log4j.appender.FILE=org.apache.log4j.FileAppender
log4j.appender.FILE.File=log.txt
log4j.appender.FILE.ImmediateFlush=true
log4j.appender.FILE.Threshold=debug
log4j.appender.FILE.Append=false
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.conversionPattern=%d{HH:mm:ss.SSS} %-4p %c{2}.%m%n
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d{HH:mm:ss.SSS} %-4p %c{2}.%m%n

What i'm missing?

Community
  • 1
  • 1
countryroadscat
  • 1,660
  • 4
  • 26
  • 49

1 Answers1

0

Try it like this:

set JAR_LOCATION=c:\any folder with spaces\jar
java -XX:-OmitStackTraceInFastThrow -cp "%JAR_LOCATION:~%" my.package.Foo

You have to remove the ":" char from %JAR_LOCATION:%, or use %JAR_LOCATION:~% to de-quote it, and quote it directly at the JAVA command, because the path probably contains spaces.

cyberponk
  • 1,585
  • 18
  • 19