Not able to enable snmp4j2.5..jar logs into java application

Hi All ,

i would like to debug snmp4j logs for each snmp request it is coming from an java application .

followed below approaches :

Approach 1) 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());

Approach 2) Enable Log4J Logging

In the main class put:

static {
LogFactory.setLogFactory(new Log4jLogFactory());

Approach 3) Enable Java Logging
To enable Java logging two steps are necessary:

static {
LogFactory.setLogFactory(new JavaLogFactory());
// Optionally set log level on root logger:

none of the above approach did not worked to push logs from snmp4j.jar to java application jar .

Any body suggest ?

Probably the problem is related to your requirement „to log into Java application“?
How does the Java application log? Where is stdout written to? …

For the Java and Log4j logging you need to define a logging format and appended in the logging framework specific manner, but when the console logging does not work the problem is more related to your expectations where the log output should appear…

Thanks for the reply .

java application logs are redirected to log file /var/log/test.log due to configuration in file something like below., file

Redirect log messages to a log file


Console appender is not enabled.
I tried enabling snmp4j jar logs into /var/log/test.log file by adding below line in file as well., file
But it didn’t worked.
Please suggest how it can be enabled.


Thank you , issue resolved

Hi @rattaiah
Can you please post how issue was resolved. This will help others facing similar issues.