Does anyone know how to enable logging for command-based programs like this?

Thank you

Hi, I have a Java batch program that is kicked by a custom CLI command.

The problem is that no logs are output in either trace.log or error.log in the /logs directory.
The code looks like this:
<pre class="java dw" data-editor-lang="java" data-pbcklang="java" dir="ltr">Groovy
def onCliTask() {
// calls the Java program
foo();
}
Java
public int foo() {
logger.log(Level.INFO, "foo called");
}
</pre>
Does anyone know how to enable logging for command-based programs like this?

Re: Logging in CLI-extended program

‏2011-11-18T20:00:50Z

This is the accepted answer.
This is the accepted answer.

I'm not able to find a sample that demonstrates that, so I'm not sure that user CLI tasks will direct log output to the default sMash logs. Assuming that you are seeing your log output showing up in stderr (meaning that your logging is working), try using the -l command line argument to capture the log messages to a logfile:

zero -l=myCliTask.log myCliTask

The output does result in a well formatted logfile, complete with timestamps.

I'm not able to find a sample that demonstrates that, so I'm not sure that user CLI tasks will direct log output to the default sMash logs. Assuming that you are seeing your log output showing up in stderr (meaning that your logging is working), try using the -l command line argument to capture the log messages to a logfile:

I believe logging.properties sets the default logging characteristics for everything (command line and non-command line). It could affect which level of log messages get captured, but INFO is the default so i don't know why you would have to edit that file, or what edit you would make for the example you posted.

Re: Logging in CLI-extended program

I believe logging.properties sets the default logging characteristics for everything (command line and non-command line). It could affect which level of log messages get captured, but INFO is the default so i don't know why you would have to edit that file, or what edit you would make for the example you posted.