Appending log files

(imported topic written by RichB91)

I have a requirement to write assorted custom information to a log file on the managed devices from within Actions. It could use either the existing Client Logs found in…

• Windows: C:\Program Files\BigFix Enterprise\BES Client__BESData__Global\Logs

• Unix/Linux: /var/opt/BESClient/__BESData/__Global/Logs

…or it could use a log file of our own creation. It could be a .txt file or .xml if that is more elegant.

It would need to work on both Windows & Unix (no Mac requirement at this time).

I would prefer, but not require, that it not use the appendfile command. For a small file it may not be a problem. But for large files, the action of duplicating the original file to _append file, appending the new line, deleting (or backing up and deleting) the original file and then moving the _appendfile to the original name & location appears to me to be more drive and CPU intensive than necessary.

On Windows I could use something like:

// store OS specific file location and name

if {name of operating system as string as lowercase contains “win”} then parameter “filename” = “C:\Company_Tools\BigFix\Logs\Custom-Log.txt” else parameter “filename” = “/var/opt/apps/tools/bigfix/logs/Custom-Log.txt”

waithidden cmd.exe /C echo.mycustomtextline1>> parameter “filename”

waithidden cmd.exe /C echo.mycustomtextline2>> parameter “filename”

But this won’t work for Unix.

Can/should custom messages be written to the existing Client Log files?

If so, how?

If not, how could custom messages be appended to an existing file without the overhead generally created by doing a three-point-turn with _appendfile?

Would editing an .xml file instead of appending a .txt make the process easier?

-RichB

(imported comment written by BenKus)

Hi RichB,

In general, I would NOT try to append data directly to the BigFix logs as this will possibly cause issues with the agent when it goes to write to the logs…

However, perhaps you can have an easy solution here because the agent will record any action line that you run… For instance, if you just run:

appendfile {now}

Then you should see that the agent logs record this value (no matter what you do with the resulting __appendfile).

So you could theoretically just add these appendfile commands to your action (as sort of like additional comments) and they will get recorded to the agent log just like any other command.

Does that help?

Ben

(imported comment written by RichB91)

I think (hope) so. Thank you.

When I test using the Fixlet Debugger, I wasn’t seeing anything written to the Client Log. I suspect it may just be different behavior in the Debugger versus the actual client. I’ll need to do a little testing.