logging capabilities

Hello,

I would like to know if the logging provided in SNMP++/AGENT++ products can do the next:

  1. Redirected to a file, if yes how to do it from a user application and how to control size of the log
    file.
  2. Can the logging level and class be changed during run time (console input or environment variable) ?

Regards,
Safet Pepeljak

Hello,

the default logging class AgentLogImpl can log to a file when logging is initialized using DefaultLog::init(new AgentLogImpl("filename"));. And log levels can be changed using DefaultLog::log()->set_filter() or DefaultLog::log()->set_profile().

There is currently no size check in AgentLogImpl, only a function to set a new log file name AgentLogImpl::set_dest(const char*) or a new file descriptor AgentLogImpl::set_dest(FILE*). So you can either add code in your application to check the file size and trigger the log file switch through these functions, or you could subclass from AgentLogImpl and do this size check inside the logging class.

Kind regards,
Jochen

1 Like

Hello Jochen,

Thank you for your prompt answer and help.
I guess as you did not mention anything about run time change of log levels/class based on environment variable value, I would need to implement it my self too, right?

Regards,
Safet

Hi Safet,

You can change the log level at runtime without any problem.
Besides doing it programmatically, you can do it via SNMP SET operations too.
See the AGENTPP-CONFIG-MIB for details.

Best regards,
Frank

Hello Frank,

Thank you. This is very useful information and exactly what I was looking for to enable logging
if I have to debug something in run time and then stop it when not needed.

Regards,
Safet