I’m developing a custom provider named “maven”, and I would like to filter logs only from my provider.
I followed the instruction in Home - Plugin Development: Managing Log Output | Terraform | HashiCorp Developer, and then I set the environment variable TF_LOG_PROVIDER_MAVEN=trace but no log is shown.
What am I missing?
Hi @kota65535,
It looks like the docs on that page could be improved a bit. Those logging options only serve to limit output from provider using the referenced libraries for logging. The Terraform CLI only knows about TF_LOG
, TF_LOG_CORE
and TF_LOG_PROVIDER
.
You can try combining that with TF_LOG_PROVIDER=trace
, but since other providers may be using the legacy logging system you will still see them in the logs. In that case it’s probably just easiest to filter the logs by the actual provider executable name as shown the log lines. While logs are relatively easy to filter as text, you also have the option of TF_LOG=json
and using the structured output too.
Hi @jbardin,
Thank you for the explanation! I’ve tried combining with TF_LOG_PROVIDER=trace
and ended up seeing logs of other providers because there are few of them using the referenced logging libraries.
As you say, it seems easier to redirect all stderr output and then filter them with grep.
Long time no see, @jbardin
I still don’t understand how this environment variable works. I tried several combinations, but it doesn’t seem to be working at all. Could you explain it a little more clearly?
Yeah, it seems the features of the plugin logging were designed outside of Terraform for development purposes, and were not expected to be compatible with the CLI. Some combinations may be able to limit provider logging output, but because the overall log levels are set by the CLI we don’t have much control.