[SNMP4J] log4J in SNMP4J

Frank Fock fock at agentpp.com
Fri Dec 7 21:15:21 CET 2012


Hi Akshay,

You do not need to write an adapter for log4j. Instead write a 
LogAdapter and LogFactory
subclass for the logging framework you are using and then register your 
factory as shown
by my last email.

Best regards,
Frank

Am 07.12.2012 16:18, schrieb Ballarpure, Akshay (NSN - IN/Hyderabad):
> log4J in SNMP4J
>
> Hi Frank,
>
> Thanks for your quick help.
>
> I have written adapter for Log4J but somehow I am not getting snmp4j 
> logs in my application. Instead MLog is using log4j.
>
> [2012-12-07 20:26:41,588] 
> INFO-main-com.motorola.nsm.common.fm.Snmp4jLog4jLogger ->logging with 
> log4j
>
> [2012-12-07 20:27:29,618] INFO-main-com.mchange.v2.log.MLog ->MLog 
> clients using log4j logging.
>
> [2012-12-07 20:27:30,362] INFO-main-com.mchange.v2.c3p0.C3P0Registry 
> ->Initializing c3p0-0.9.1.2 [built 21-May-2007 15:04:56; debug? true; 
> trace: 10]
>
> [2012-12-07 20:27:30,505] 
> DEBUG-main-com.mchange.v2.c3p0.management.DynamicPooledDataSourceManagerMBean 
> ->MBean: 
> com.mchange.v2.c3p0:type=PooledDataSource[2ubb0o8rwpdsju1bco7sk|1256a73] 
> registered.
>
> [2012-12-07 20:27:30,612] 
> DEBUG-main-com.mchange.v2.c3p0.management.DynamicPooledDataSourceManagerMBean 
> ->MBean: 
> com.mchange.v2.c3p0:type=PooledDataSource[2ubb0o8rwpdsju1bco7sk|1256a73] 
> unregistere
>
> d, in order to be reregistered after update.
>
> [2012-12-07 20:27:30,612] 
> DEBUG-main-com.mchange.v2.c3p0.management.DynamicPooledDataSourceManagerMBean 
> ->MBean: 
> com.mchange.v2.c3p0:type=PooledDataSource[2ubb0o8rwpdsju1bco7sk|1256a73] 
> registered.
>
> [2012-12-07 20:27:30,831] 
> INFO-main-com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource 
> ->Initializing c3p0 pool... 
> com.mchange.v2.c3p0.PoolBackedDataSource at fbb4271d [ 
> connectionPoolDataSource ->
>
> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource at 4575bfa2 [ 
> acquireIncrement -> 10, acquireRetryAttempts -> 30, acquireRetryDelay 
> -> 1000, autoCommitOnClose -> false, automaticTestTable -> null
>
> , breakAfterAcquireFailure -> false, checkoutTimeout -> 0, 
> connectionCustomizerClassName -> null, connectionTesterClassName -> 
> com.mchange.v2.c3p0.impl.DefaultConnectionTester, debugUnreturnedConne
>
> ctionStackTraces -> false, factoryClassLocation -> null, 
> forceIgnoreUnresolvedTransactions -> false, identityToken -> 
> 2ubb0o8rwpdsju1bco7sk|7d093a, idleConnectionTestPeriod -> 0, 
> initialPoolSize ->
>
> 1, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime 
> -> 0, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 100, 
> maxStatements -> 500, maxStatementsPerConnection -> 0, minPoolSiz
>
> e -> 1, nestedDataSource -> 
> com.mchange.v2.c3p0.DriverManagerDataSource at 481d25e9 [ description -> 
> null, driverClass -> null, factoryClassLocation -> null, identityToken 
> -> 2ubb0o8rwpdsju1bco7sk|72f
>
> e25, jdbcUrl -> jdbc:oracle:thin:@nsn-sb-fm:1521:MotoMgDb, properties 
> -> {user=******, password=******, autocommit=true, release_mode=auto} 
> ], preferredTestQuery -> null, propertyCycle -> 0, testCo
>
> nnectionOnCheckin -> false, testConnectionOnCheckout -> false, 
> unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> 
> false; userOverrides: {} ], dataSourceName -> null, factoryClass
>
> Location -> null, identityToken -> 2ubb0o8rwpdsju1bco7sk|1256a73, 
> numHelperThreads -> 80 ]
>
> [2012-12-07 20:27:30,978] 
> DEBUG-main-com.mchange.v2.resourcepool.BasicResourcePool ->incremented 
> pending_acquires: 1
>
> [2012-12-07 20:27:30,979] 
> DEBUG-main-com.mchange.v2.resourcepool.BasicResourcePool 
> ->com.mchange.v2.resourcepool.BasicResourcePool at 141d19 config: [start 
> -> 1; min -> 1; max -> 100; inc -> 10; num_a
>
> cq_attempts -> 30; acq_attempt_delay -> 1000; 
> check_idle_resources_delay -> 0; mox_resource_age -> 0; max_idle_time 
> -> 0; excess_max_idle_time -> 0; destroy_unreturned_resc_time -> 0; 
> expiration_en
>
> forcement_delay -> 0; break_on_acquisition_failure -> false; 
> debug_store_checkout_exceptions -> false]
>
> [2012-12-07 20:27:30,980] 
> DEBUG-main-com.mchange.v2.resourcepool.BasicResourcePool ->acquire 
> test -- pool size: 0; target_pool_size: 1; desired target? 1
>
> [2012-12-07 20:27:30,980] 
> DEBUG-main-com.mchange.v2.resourcepool.BasicResourcePool ->incremented 
> pending_acquires: 2
>
> [2012-12-07 20:27:30,980] 
> DEBUG-main-com.mchange.v2.resourcepool.BasicResourcePool ->incremented 
> pending_acquires: 3
>
> [2012-12-07 20:27:30,981] 
> DEBUG-main-com.mchange.v2.resourcepool.BasicResourcePool ->incremented 
> pending_acquires: 4
>
> [2012-12-07 20:27:30,981] 
> DEBUG-main-com.mchange.v2.resourcepool.BasicResourcePool ->incremented 
> pending_acquires: 5
>
> [2012-12-07 20:27:30,981] 
> DEBUG-main-com.mchange.v2.resourcepool.BasicResourcePool ->incremented 
> pending_acquires: 6
>
> [2012-12-07 20:27:30,982] 
> DEBUG-main-com.mchange.v2.resourcepool.BasicResourcePool ->incremented 
> pending_acquires: 7
>
> [2012-12-07 20:27:30,982] 
> DEBUG-main-com.mchange.v2.resourcepool.BasicResourcePool ->incremented 
> pending_acquires: 8
>
> [2012-12-07 20:27:30,982] 
> DEBUG-main-com.mchange.v2.resourcepool.BasicResourcePool ->incremented 
> pending_acquires: 9
>
> [2012-12-07 20:27:30,982] 
> DEBUG-main-com.mchange.v2.resourcepool.BasicResourcePool ->incremented 
> pending_acquires: 10
>
> [2012-12-07 20:27:30,983] 
> DEBUG-main-com.mchange.v2.resourcepool.BasicResourcePool ->incremented 
> pending_acquires: 11
>
> [2012-12-07 20:27:30,984] 
> DEBUG-main-com.mchange.v2.resourcepool.BasicResourcePool 
> ->awaitAvailable(): [unknown]
>
> *I have attached adapter code..do let me know if any issues.*
>
> --
>
> With Thanks & Regards,
>
> *Akshay Ballarpure*
>
> (Office: +91-40-4472-*4112*
>
> *From:*ext Frank Fock [mailto:fock at agentpp.com]
> *Sent:* Thursday, December 06, 2012 11:19 PM
> *To:* Ballarpure, Akshay (NSN - IN/Hyderabad)
> *Cc:* snmp4j at agentpp.org
> *Subject:* Re: log4J in SNMP4J
>
> Hi,
> Simply call
>
> static {
>   LogFactory.setLogFactory(new Log4jLogFactory());
> }
>
> in your main class.
>
> Best regards,
> Frank
>
> Am 06.12.2012 15:19, schrieb Ballarpure, Akshay (NSN - IN/Hyderabad):
>
>     Can someone help me how to use log4j in snmp4j.. any sample code
>     if available would help.
>
>     Urgent reply is appreciated...
>
>     --
>
>     With Thanks & Regards,
>
>     *Akshay Ballarpure*
>
>     (Office:  +91-40-4472-*4112*
>
>
>
> -- 
> ---
> AGENT++
> Maximilian-Kolbe-Str. 10
> 73257 Koengen, Germany
> https://agentpp.com
> Phone: +49 7024 8688230
> Fax:   +49 7024 8688231

-- 
---
AGENT++
Maximilian-Kolbe-Str. 10
73257 Koengen, Germany
https://agentpp.com
Phone: +49 7024 8688230
Fax:   +49 7024 8688231




More information about the SNMP4J mailing list