logging
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| logging [2018/01/12 09:21] – pawel | logging [2026/02/01 12:29] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| You can add script runner logging to any script by adding code to your script. The log will be displayed both in catalina.out log file and in the script step (although this is delayed). To add the logging, add the following to your script: | You can add script runner logging to any script by adding code to your script. The log will be displayed both in catalina.out log file and in the script step (although this is delayed). To add the logging, add the following to your script: | ||
| - | < | + | < |
| import org.apache.log4j.Logger | import org.apache.log4j.Logger | ||
| import org.apache.log4j.Level | import org.apache.log4j.Level | ||
| Line 11: | Line 11: | ||
| | | ||
| log.debug(" | log.debug(" | ||
| + | </ | ||
| + | |||
| + | ==== ScriptRunner Console script to ping a server ==== | ||
| + | If you want to run a query to ping a server, or IP address, you can use the following script replacing 8.8.4.4 with the server ip or name that you're interested in: | ||
| + | <code java> | ||
| + | import org.apache.log4j.Logger | ||
| + | import org.apache.log4j.Level | ||
| + | |||
| + | def log = Logger.getLogger(" | ||
| + | log.setLevel(Level.DEBUG) | ||
| + | |||
| + | |||
| + | def proc = 'ping -c 3 8.8.4.4' | ||
| + | proc.waitFor() | ||
| + | def output = proc.text | ||
| + | println "Ping ${proc.exitValue() == 0 ? ' | ||
| + | |||
| + | log.debug(" | ||
| </ | </ | ||
| ==== Message to the end user ==== | ==== Message to the end user ==== | ||
| - | < | + | < |
| import com.onresolve.scriptrunner.runner.util.UserMessageUtil | import com.onresolve.scriptrunner.runner.util.UserMessageUtil | ||
| - | // Successful Action Message | + | // Successful Action Message |
| UserMessageUtil.success(" | UserMessageUtil.success(" | ||
logging.1515766904.txt.gz · Last modified: (external edit)
