0

I have a custom backup process, that at the end produces a log file.

I would like to send the log to stackdriver, and for that I am doing:

gcloud beta logging write log "!content!"
pause

Where content is a variable containing the entire file content.

I can't use any other language other then batch for this, and this is not working.

It doesn't even pause at the end.

If I do:

gcloud beta logging write log "Could not locate %filename%" --severity=ERROR

It works. so probably it is the file size (15MB) or the fact that it is multiple lines.

How can I log a log file with stackdriver cli?

Amit
  • 5,924
  • 7
  • 46
  • 94
  • Yeah, batch variable length is limited to 8192 characters. You _might_ be able to pipe the content in, like `type %filename%|gcloud beta logging write log`, but frankly this entire mechanism is so terribly designed that I refuse to believe there isn't an option to simply pass a file name. – SomethingDark May 14 '17 at 00:21

1 Answers1

0

Rather inexperienced with Google Cloud Platform and Stackdriver but solely based on the documentation of the gcloud beta logging write command, it seems that the command is designed for writing simple log entries one at the time.

Don't consider this as the final answer to your problem. I'm convinced that there must be someone out there who can come up with a proper solution. But as a temporary quick-fix workaround you could parse each individual file line to the gcloud beta command.

:: Be aware of gigantic files   
for /f "delims=" %%a in ("%filename%") do gcloud beta logging write log "%%a"
303
  • 2,417
  • 1
  • 11
  • 25