SNMP4J provides its own log framework adapter that allows to plugin virtually any logging framework, including Java logging and Log4J.

Enable Simple Logging

In the main class execute the following code before any SNMP4J code is executed statically or at runtime:

static {
    LogFactory.setLogFactory(new ConsoleLogFactory());
    ConsoleLogAdapter.setDebugEnabled(true);
}

Enable Log4J Logging

In the main class put:

static {
  LogFactory.setLogFactory(new Log4jLogFactory());
  org.apache.log4j.BasicConfigurator.configure();
  LogFactory.getLogFactory().getRootLogger().setLogLevel(LogLevel.ALL);
}