[AGENT++] Loging in Files

Martin Janzen janzen at pixelmetrix.com
Wed Jun 16 10:30:16 CEST 2004


Brunck, Holger wrote:
> Hello,
> I'm using the SNMP Master Agent. It works fine but I can't find out who to
> adjust the agent, for logging all messages into a file instead of stdout. 
>  At this time I'm using the DefaultLog 
>  
> DefaultLog::log()->set_filter(ERROR_LOG, 2);
> DefaultLog::log()->set_filter(WARNING_LOG, 2);
> DefaultLog::log()->set_filter(EVENT_LOG, 5);
> DefaultLog::log()->set_filter(INFO_LOG, 5);
> DefaultLog::log()->set_filter(DEBUG_LOG, 5);
>  
> How can I setup an own log that logs everything into a file?

The DefaultLog singleton creates an instance of AgentLogImpl using the 
default ctor, which logs to stdout.  You'd simply need to replace that 
with a different instance of AgentLogImpl that logs to your own file:

   DefaultLog::init(new AgentLogImpl("/tmp/my_log_file"));

or

   FILE* fp = fopen(...);
   DefaultLog::init(new AgentLogImpl(fp));

-- 
Martin Janzen
janzen at pixelmetrix dot com



More information about the AGENTPP mailing list