netopeer2 icon indicating copy to clipboard operation
netopeer2 copied to clipboard

Dedicated file logger for netopeer2/netconf

Open Krisscut opened this issue 1 year ago • 4 comments

Hi !

This is a feature request/proposal. Are you open to the idea of having a dedicated log file in parallel to the usual console logger to log all the netconf related messages ? I want to have it separate to the main console output so that I can have both enabled at the same time, but keep the main log at info level for usual operation and the logfile at a more "debug" level to always have the rpc traces available. (I know that it is possible to have the messages in the console output using MSG option)

This is quite useful for instance to see at a glance the content of all the requests/replies transiting through the netopeer2-server. We can also then parse the file using a tool like https://github.com/AeroFlorian/netconf-parser

On my end I did it patching netopeer2-server (to alter the nc logging callback and create the log file) + the libnetconf itself to filter the display of the get-schema replies. (which are pretty huge)

I attached an example output: netconf_trace_example.log

And its view in the tool I mentioned: image

This is a similar subject as https://github.com/CESNET/Netopeer2/issues/307

Krisscut avatar Sep 16 '24 12:09 Krisscut

No problem, if you create a nice PR, I will merge it. Just make sure the code is clean and all the new features optional.

michalvasko avatar Sep 17 '24 07:09 michalvasko

Hi @Krisscut Appreciate you bringing this up! I'm looking for the same file logging feature. Would you mind sharing your patch or submitting a PR?

nileshjagtap45 avatar Apr 10 '25 04:04 nileshjagtap45

Hi @nileshjagtap45

I unfortunately never had time to prepare a pull request with a nice and clean way to do this, here are the patches tho (might not apply because I had to remove unrelated things that was bundled inside it as well).

There is a patch in netopeer2 and another one for libnetconf2. And it avoids the display of the schema exchange because they can be huge !

Note that I enabled verbosity to DBG in netopeer2 in the patch because in our case we actually control the logging through the log callback so we check the log level there.

netopeer2-2.2.13.patch libnetconf2-3.0.11.devel.patch

Example expected log output:

Image

[ ... later on ...] Image

Krisscut avatar Apr 10 '25 12:04 Krisscut

Thanks for the quick response and sharing the patches—really appreciate it!

nileshjagtap45 avatar Apr 10 '25 12:04 nileshjagtap45