hashicorp / packer

Packer is a tool for creating identical machine images for multiple platforms from a single source configuration.
http://www.packer.io
Other
15.07k stars 3.33k forks source link

FR: Use log4go for logging #7244

Open danowar2k opened 5 years ago

danowar2k commented 5 years ago

I think it would be helpful if Packer would use log4go or a similar logging framework. At the moment you can only say "Log on", "Log off" and where the log file should be placed. You have hardcoded log levels which are always outputted. You can't enable or disable logging of specific modules. You can't provide very wordy logging because log files would get enormous.

Using log4go or something would enable you to produce really detailed logs (e.g. SSH configuration object content or something like it). For my current problem with SSH there are definitely not enough log messages in the code, or so it seems.

SwampDragons commented 5 years ago

If you're experiencing a problem getting SSH set up, then it's likely that the problem is either a network problem or that your preseed/kickstart file for your vm is not getting ssh set up properly; that's not something that changing the logger will help.

It does sound nice to be able to have more flexible logging, but this isn't going to be high on my priority list. I'll leave this issue open in case someone in the community wants to try to implement it.

danowar2k commented 5 years ago

Good catch :-) Yeah, I'm experiencing issues connecting to the VM when the SSH server should (!) be up on the VM. (As can be deduced from comments in other tickets).

I think at the moment that the issue is either SSH configuration or something in my Solaris VM (this OS...), so I need to activate verbose SSH output...which I'll only get by recompiling Packer (or rather the SSH library) myself, it seems.

Anyway, I looked through the Packer code and was surprised that the log entries had hardcoded "[DEBUG]" etc. strings in them, which could either be activated or ... not. I'd like to add debug log messages in multiple locations, but I'm unsure whether a Pull Request containing a massive amount of additional log messages would be accepted. If log4go or something like it would be used, I could relegate the log messages to a really verbose level.

Anyway, I have good experience with log4X frameworks, so I requested it. I'm aware that this may not be high priority. I just wanted the request recorded for the future.

Next thing for me is to get to make Packer on Windows and hopefully reproduce my problem with that build and additional messages...

SwampDragons commented 5 years ago

It depends on where the log messages are, but I generally don't mind adding extra logging.

azr commented 5 years ago

It might also be worth to note the existence of https://github.com/hashicorp/logutils in this case. This would allow to select what is outputted like you'd like without having to change every log line.