zippy1978 / ghost4j

Java wrapper for Ghostscript C API + PS/PDF document handling API
http://www.ghost4j.org
GNU Lesser General Public License v3.0
64 stars 39 forks source link

Ghost4j log4j is not responding properly. #11

Closed rameswar closed 11 years ago

rameswar commented 11 years ago

Hi,

I do not want log the msg into log file. So I set Level as OFF. But it is not responding. public static void main(String[] args) { String[] gsArgs = new String[8]; gsArgs[0] = "-q"; gsArgs[1] = "-dNOPAUSE"; gsArgs[2] = "-r300"; gsArgs[4] = "-sDEVICE=tiffg4"; gsArgs[5] = "-dBATCH"; gsArgs[6] = "-sstdout=gs.log"; gsArgs[7] = "-sOutputFile=123.tif"; gsArgs[7] = "123.pdf"; GhostscriptLoggerOutputStream gsloggerOutStream = new GhostscriptLoggerOutputStream(Level.OFF); Ghostscript ghostscript = Ghostscript.getInstance(); ghostscript.setStdOut(gsloggerOutStream); ghostscript.setStdErr(gsloggerOutStream);
try { gs.initialize(gsArgs); gs.exit(); } catch (GhostscriptException e) { e.printStackTrace(); System.out.println("ERROR: " + e.getMessage()); } }

Regards, Rameswar

zippy1978 commented 11 years ago

Hi, Where do you see the log messages ? If it is in gs.log : this is normal : Java is by passed if you redirect directly gs stdout. Did you try removing your "-sstdout" switch and setting a Java logger to log org.ghost4j messages to a file ?

rameswar commented 11 years ago

Hello,

The thing is I added the log4j.properties to the classpath and then I tried not log into that "xyz.log" file(Which is not the stdout related log file). But it is still logging into the xyz.log file.

Log4j.properties details:

log4j.rootLogger=DEBUG, stdout, R

log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%d{MMM dd, yyyy HH:mm:ss} %5p (%F:%L) - %m%n

log4j.appender.R=org.apache.log4j.RollingFileAppender log4j.appender.R.File=c:\xyz.log log4j.appender.R.MaxFileSize=1000KB log4j.appender.R.MaxBackupIndex=10 log4j.appender.R.layout=org.apache.log4j.PatternLayout log4j.appender.R.layout.ConversionPattern=%d{MMM dd, yyyy HH:mm:ss} %p %c - %m%n

I tried the previous posted program with this log4j details but it is still logging into the log4j log file.

Regards, Rameswar

zippy1978 commented 11 years ago

Ok : if you modify GhostscriptLoggerOutputStream to stop logging by adding a command on the log line. Does it still log ?

rameswar commented 11 years ago

Hello,

The program which is on top, there I am trying not to log in the log4j related log file. But still it's logging. After setting the GhostscriptLoggerOutputStream as Level.OFF. So I want to log into some other file in place of the default log4j logging file. But the thing is in Ghost4j I am unable to get the control of the logging mechanism. How can I do this?

Regards, Rameswar

zippy1978 commented 11 years ago

Write your own GhostscriptLoggerOutputStream

rameswar commented 11 years ago

Hi, I configured the Log4j in different way by which it's able to log all the log4j msg into separate log file.

Thanks for your quick replies and suggestions.

zippy1978 commented 11 years ago

Good !