Kaseya Community

Write contents of file to agent log?

  • Is there a way to do this through a script?

  • Get Variable - File content - specify the file you want.

    Next step write to procedure log Value = #myvariable#

    This will collect the content from the file store it in a variable then you write it to the script log.

  • Adding a little further to this,

    Is there a limit on how many characters can be written to script log at a time as some of my gathering scripts just output 2 ascii characters and it seems to be the ones with lots of text.

  • according to DB the description field is a varchar(1000) so I would say 1000 characters.

    thing to do is ensure it is reading it - so before or after the write procedure log entry - do a send mail command and check the mail to see is the full contents in the email.

  • I have seen it create multiple Agent Procedure/script log entries when it go's over the limit, the down side with doing this from what I have seen is that you don't retain the formatting of the original log file.

  • Watch out, this can get ugly.

    Writing the contents of a file to the script log are good for one liners, like "the command completed successfully" Anything much more than that is a total mess in the log, although you can fit a much large mess in there, you won't want to in the end.

    You are probably better off to write the script to upload the log file to the documents tab, and if you want a script log entry for this. Have it refer to the document tab for the file.

    I.e. write script log entry:  The log file for [script action] has been uploaded to the documents tab in [../Docs/#filename#]

    I'm guessing you are wanting to run a report against the log? If so, you are probably better off to use the under-utilitzed, and not often talked about, Custom Log Parser. That way you only "upload" the parts of the log file you are interested in by defining it in the parser set, and it makes for easier log viewing, and reporting. The trick is to get the Log Parser to work in the first place.

  • @tlctech  just curious, what are you trying to do this for? Don't get me wrong here, I'm just curious to see what people are using the script logs for. I usually find them very helpful in seeing why a script failed.

  • I agree with myArch-man using the Get File command to upload your log files to the Agent folders on the Kserver is a better solution and using one liners for the Agent Procedure/Script log is the way to go.