Different logging levels for different components?

Hello (Hello! Long time reader, first time poster!),

I have my logging.log_level set to INFO in my config and I get the verbose logging, which is great. But I’d like to quiet certain components. For example, I’d like full_node to be at WARNING.

The YAML is using pointers to the farmer.logging property. Does anyone know if I can create a new logging property at top level, say a “quiet logging” node that I can then reference in components I want to just be quiet already?

Now I’ve just thought of another idea: I don’t have to point to the farmer logging – I could just remove the pointer and have a different logging configuration on each component that I want different.

Anyway, ideas are welcome. Thanks for reading my first post!

Well, I’ve answered my own question. I suppose writing out the problem helped. I’ll explain explicitly in case it helps anyone else, especially those not in technical work.

At the bottom of config.yaml, there is a general logging property. I modified that to be my default logging configuration and gave it an address of defaultlog, like so:

logging: &defaultlog
  log_filename: log/main.log
  log_level: WARNING
  log_maxfilesrotation: 7
  log_stdout: false

Then in the logging property for each component, I could refer to that top-level logging config. For example, here is full_node:

full_node:
  logging: *defaultlog

Then in my harvester, I configured an entirely different logger:

harvester:
  logging:
    log_filename: log/harvester.log
    log_level: INFO
    log_maxfilesrotation: 30

It all appears to be working so far. I hope this helps others!

3 Likes

Thank you. That’s was very helpful!

1 Like

Or so I thought that this would be nice. I replaced just the harvester entry with your above and when I relaunched, I got the spinner for plots and farm in the gui. It didn’t finish and farm, at least as long as I waited. Did I miss something, did I need to add something else? How did you get it to work?

I did end up adding a log_stdout: false setting as well. I’m using CLI on Linux but it shouldn’t affect the GUI, as far as I know. Maybe it’s a bug.

Here’s a screenshot of that section. Since it’s YAML, make sure you’re using two spaces to indent each level.

And a paste of the entry:

harvester:
  logging:
    log_filename: log/harvester.log
    log_level: INFO
    log_maxfilesrotation: 30
    log_stdout: false

I hope that helps. I’ll try it on my GUI client on my desktop and see if I get the same problem.

Thanks! I try it again. I’d copied and pasted last time, but I’ll make sure this time with the indents. Yes, Win10 GUI. It may be a while, I just started a 70 plot schedule going this noon… so a few days likely before restarting…

I just tried it in my GUI on MacOS and it worked fine. Hopefully the indents were the fix. Go, plots, go!

Yes, works for me too. Great idea you came up with! Rather than parse the general log, this makes it super easy to see what you care about. IMHO should have been this way originally.

1 Like

Discovered a bit of a frustrating thing. Upgrade .chia and any custom changes to .yaml get reset to defaults, wiping mods like this. Something to remember every upgrade.

Oh, interesting. GUI upgrades wipe and reset .chia/mainnet/config/config.yaml?

I use CLI and it doesn’t change those settings on upgrade. I should check to make sure my config is being migrated with new settings — I believe it updated it with pooling configuration. Thanks for the reminder!

We should also note that if anyone does this, some monitoring tools like Chiadog may not work correctly. When I looked at the Chiadog config options, it only took one log file to inspect. I might be wrong but heads up just in case.