This article provides information on how to capture CopyStorm job execution log data that is output via Standard Error/Out in a text file. This approach is useful for doing advanced troubleshooting in order to capture error symptoms that may not appear within the application GUI or within the logged exceptions of the job history entry found on the βHistoryβ tab.
The general approach is as follows:
Open a headless CopyStorm script for editing.
This is the script that is scheduled using CRON or Windows Task Scheduler, and is created using the βBatch Fileβ tab of CopyStorm.
Create a directory that will be used to save the application logs.
Edit the batch script to create a log file with the appropriate name in the established directory and write all job execution output to the file.
Here is an unedited example of a Windows batch script generated by CopyStorm. This script will be modified to output CopyStorm job logs to a file:
The following code is added after the line that begins with βSET CopyStormConfigFileβ
This code sets a local script variable that establishes the path to the directory where the log files will be stored.
The βC:\Capstorm\CopyStormLogsβ path should point to your desired CopyStorm log directory path.
Next, the second to last line (starting with βCALL %CopyStormCmd%β) will need to be modified to write to the logfile. The final line will look like this:
This code creates a logfile and redirects stderr and stdout to the file, capturing all job execution logs.
The βCopyStorm_Log_β prefix is used to identify the type of logfile β if you have multiple scheduled jobs, it is best practice to use a different prefix for each scheduled job. For example, βCopyStorm_Hourly_Data_β and βCopyStorm_Daily_Metadata_β if there is an hourly job for data and a separate daily job for metadata.
The example above will create log files with names like:
CopyStorm_Log_2023-02-21T19-45-32.txt
Here is an edited version of the batch script shown above:
Here is an unedited example of a Linux sh script generated by CopyStorm. This script will be modified to output CopyStorm job logs to a file:
The following code is added after the line that begins with βCopyStormConfigFile=β
This code sets a local script variable that establishes the path to the directory where the log files will be stored.
The β/opt/Capstorm/CopyStormLogsβ path should point to your desired CopyStorm log directory path.
Next, the second to last line (starting with βsh $CopyStormRootDirβ) will need to be modified to write to the logfile. The final line will look like this:
This code creates a logfile and redirects stderr and stdout to the file, capturing all job execution logs.
The βCopyStorm_Log_β prefix is used to identify the type of logfile β if you have multiple scheduled jobs, it is best practice to use a different prefix for each scheduled job. For example, βCopyStorm_Hourly_Data_β and βCopyStorm_Daily_Metadata_β if there is an hourly job for data and a separate daily job for metadata.
The example above will create log files with names like:
CopyStorm_Log_2023-02-21T19:45:32.txt
Here is an edited version of the batch script shown above:
You do not need to change any of this code, just copy and paste it directly.
You do not need to change any of this code, just copy and paste it directly.
@ECHO OFF
REM
REM This script runs CopyStorm and relies on the notification system built into CopyStorm
REM to report the success/failure of a job. Log file information is written to stdout
REM in addition to the logging tables in the CopyStorm database.
REM
REM CopyStormRootDir - the directory in which CopyStorm is installed.
REM CopyStormConfigFile -- the name of the CopyStorm configuration file to run.
SET CopyStormRootDir=C:\Capstorm\CopyStorm
SET CopyStormConfigFile=C:\Capstorm\CapstormConfig\config.copyStorm
SET CopyStormCmd="%CopyStormRootDir%\CopyStorm.bat" -run "%CopyStormConfigFile%"
CALL %CopyStormCmd% 2>&1
EXIT /B %ERRORLEVEL%SET LOGDIR=C:\Capstorm\CopyStormLogsSET TIMESTAMP=%date:~10,4%-%date:~7,2%-%date:~4,2%T%TIME::=-%
SET TIMESTAMP=%TIMESTAMP: =0%CALL %CopyStormCmd% >> %LOGDIR%\CopyStorm_Log_%TIMESTAMP%.txt 2>&1
@ECHO OFF
REM
REM This script runs CopyStorm and relies on the notification system built into CopyStorm
REM to report the success/failure of a job. Log file information is written to stdout
REM in addition to the logging tables in the CopyStorm database.
REM
REM CopyStormRootDir - the directory in which CopyStorm is installed.
REM CopyStormConfigFile -- the name of the CopyStorm configuration file to run.
SET CopyStormRootDir=C:\Capstorm\CopyStorm
SET CopyStormConfigFile=C:\Capstorm\CapstormConfig\config.copyStorm
SET LOGDIR=C:\Capstorm\CopyStormLogs
SET TIMESTAMP=%date:~10,4%-%date:~7,2%-%date:~4,2%T%TIME::=-%
SET TIMESTAMP=%TIMESTAMP: =0%
SET CopyStormCmd="%CopyStormRootDir%\CopyStorm.bat" -run "%CopyStormConfigFile%"
CALL %CopyStormCmd% >> %LOGDIR%\CopyStorm_Log_%TIMESTAMP%.txt 2>&1
EXIT /B %ERRORLEVEL%
#!/bin/sh
#############################################################################
# This script runs CopyStorm and relies on the notification system built into CopyStorm
# to report the success/failure of a job. Log file information is written to stdout
# in addition to the logging tables in the CopyStorm database.
#
# CopyStormRootDir - the directory in which CopyStorm is installed.
# CopyStormConfigFile -- the name of the CopyStorm configuration file to run.
#
#############################################################################
CopyStormRootDir="/opt/Capstorm/CopyStorm"
CopyStormConfigFile="/opt/Capstorm/CopyStormConfig/configFile.copyStorm"
sh $CopyStormRootDir/CopyStorm.sh -run $CopyStormConfigFile 2>&1
exit $?
LOGDIR="/opt/Capstorm/CopyStormLogs"TIMESTAMP=$(date +"%Y-%m-%dT%H:%M:%S")
sh $CopyStormRootDir/CopyStorm.sh -run $CopyStormConfigFile >> "$LOGDIR/CopyStorm_Log_$TIMESTAMP.txt" 2>&1#!/bin/sh
#############################################################################
# This script runs CopyStorm and relies on the notification system built into CopyStorm
# to report the success/failure of a job. Log file information is written to stdout
# in addition to the logging tables in the CopyStorm database.
#
# CopyStormRootDir - the directory in which CopyStorm is installed.
# CopyStormConfigFile -- the name of the CopyStorm configuration file to run.
#
#############################################################################
CopyStormRootDir="/opt/Capstorm/CopyStorm"
CopyStormConfigFile="/opt/Capstorm/CopyStormConfig/configFile.copyStorm"
LOGDIR="/opt/Capstorm/CopyStormLogs/"
TIMESTAMP=$(date +"%Y-%m-%dT%H:%M:%S")
sh $CopyStormRootDir/CopyStorm.sh -run $CopyStormConfigFile >> "$LOGDIR/CopyStorm_Log_$TIMESTAMP.txt" 2>&1
exit $?