Page History
...
Access
...
Log Object
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
$logs = Get-JS7TaskHistory | Get-JS7TaskLog |
...
A task log object carries a number of attributes as visible from the following console example:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
PS /> $logs = Get-JS7TaskHistory | Get-JS7TaskLog PS /> $logs[0] controllerId : jobscheduler agentUrl : http://apmaccs:4449 taskId : 15247 orderId : #2022-03-06#P31960629618-pdCyclicSimpleWorkflowTicking workflow : /ProductDemo/CyclicExecution/pdCyclicSimpleWorkflowTicking position : 0/cycle+end=1646607600000,scheme=1,i=10,next=1646564721361:2 job : job3 criticality : normal exitCode : 0 state : @{severity=6; _text=SUCCESSFUL} startTime : 06.03.2022 12:05:31 endTime : 06.03.2022 12:05:36 log : 2022-03-06 12:05:31.388+0100 [MAIN] [Start] Job=job3, Agent (url=http://apmaccs:4449, id=agent_002) 2022-03-06 12:05:31.795+0100 [STDOUT] using workflow: pdCyclicSimpleWorkflowTicking running job: job3 2022-03-06 12:05:36.399+0100 [MAIN] [End] [Success] returnCode=0 |
Write
...
Log to File
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
Get-JS7TaskHistory | Get-JS7TaskLog | Out-File /tmp/history/tasks.log -Encoding Unicode |
...
Provides a mechanism to subsequently retrieve previous logs. Starting from initial execution of the
Get-JS7TaskHistory
cmdlet the resulting$lastHistory
object is used for any subsequent calls.
Consider use of theTee-Object
cmdlet in the pipeline that updates the$lastHistory
object that can be used for later executions of the same pipeline.This pipeline can e.g. be executed in a cyclic job.
Automate
...
Log File Creation
A workflow is created that runs the above commands in a cycle. The workflow operates 24/7 and writes task logs to files.
...
- Lines 1, 4: Same explanations as for the previous job.
- Lines 7,8: The History ID of the last processing of this job is picked up from an environment variable that is assigned the workflow variable previously serialized and base64-encoded.
Line 10: When reading the task history then the variable carrying the History ID is updated and is forwarded to the workflow for next execution of the cycle.
...