jlog, jtool log
jlog
lets you log using the Redwood Logging format. You can call it as jlog
or jtool log
.
Note: For installation instructions, see jtool
.
Syntax
jlog [-h|-?|-help] [-l <loglevel>] [-f <logfile>] [-e|-exit <value>] [-c|-category <category>]
[-n|-name <name>] <level> <message> ...
Argument | Default | Description |
---|---|---|
-h, -?, -help |
|
Shows the help. |
-l <loglevel> |
${JCS_LOGLEVEL:-info}
|
Sets the log level. |
-f <logfile> |
${JCS_LOGFILE:-stderr}
|
Logs to a file instead of stdout and stderr . |
-j, -job-context |
|
Gets the environment from the job context. |
-e,-exit <value> |
|
Exits with the given return code. |
-c, -category <category> |
${JCS_LOG_CATEGORY:-custom.log}
|
The category. |
-n, -name <name> |
${JCS_LOG_NAME:-jlog}
|
The name of the component. |
<level>
|
|
The log level. |
<message>
|
|
A message to log. |
Process Server Parameters and Environment Variables
Use the ${<name>}
syntax to specify Process Server parameter values. Note that if you shell interprets ${<val>}
, you will have to escape the expression according to your shell. Any Process Server parameter that has remote
set to true
can be accessed in this way. The special ${LISTALL}
variable contains a list of all environment variable and Process Server parameters.
jtool log -n myTool -j 'DataRootDirectory: ${DataRootDirectory}'
You can use this outside of job-context
, but only environment variables will be available.
Note: jlog
expects a correctly escaped environment variable name for your shell. Make sure the shell does not evaluate the variable. Numerous examples are available below.
Example
The LogLevel Process Server parameter is set to jlog.my.category=debug
. The following UNIX shell example shows how to log.
jlog -n myproject -c my.category debug "This will be printed to the log"
jlog -n myproject -c my.category info "This will be printed to the log"
jlog -n myproject -c my.other.category debug "This will NOT be printed to the log; the category does not match"
jlog -n myproject -c my.category trace "This will NOT be printed to the log, the verbosity level is too high"
jlog -n myproject -c my.category info "This will be printed to the log, mentioning the value ${BustWatchDirectory} of the Process Server parameter with the name BustWatchDirectory"