segunda-feira, 21 de julho de 2014

Como habilitar log SQL statement no DB Adapter

As vezes temos problemas com a execução de um DB Adapter, e logar os SQL statements e os binds é muito útil nesses momentos.
Irei demonstrar como configurar no SOA Suite para logar o SQL Statement e os binds.

Passos:

1-) Entre em seu console (http://<IP>:<PORT>/console) e navegue até a aba "Debug". (Environment -> Servers -> AdminServer -> Debug)



2-) Vá em "weblogic -> jdbc -> sql" selecione a opção "DebugJDBCSQL" e clique em "Enable"



3-) Entre o enterprise manager (http://<IP>:<PORT>/em), clique com o direito em soa-infra e selecione a opção  "Logs -> Log Configuration".



4-) Vá em "oracle.soa -> oracle.soa.adapter" e selecione no combo box  opção "Trace:1 (FINE)"


Pronto, o seu ambiente está configurado para logar os SQL statement e os binds, verifique no arquivo de log e verá algo parecido como exemplo abaixo.

Em  <DOMAIN_HOME>/servers/AdminServer/logs/AdminServer.log:

-->SQL Statement
####<07/07/2014 16h54min56s BRT> <Debug> <JDBCSQL> <localhost> <AdminServer> <[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <BEA1-050CCC6E57BB175B1571> <11d1def534ea1be0:3847d2ea:1471260b38f:-8000-0000000000000145> <1404762896694> <BEA-000000> <[[weblogic.jdbc.wrapper.JTAConnection_weblogic_jdbc_wrapper_XAConnection_oracle_jdbc_driver_LogicalConnection-HR-4, oracle.jdbc.driver.LogicalConnection@fb0e8a]] prepareStatement(SELECT DEPARTMENT_ID, DEPARTMENT_NAME, MANAGER_ID, LOCATION_ID FROM DEPARTMENTS WHERE (DEPARTMENT_ID = ?))>
.
.
.
-->Bind parameter
####<07/07/2014 16h54min56s BRT> <Debug> <JDBCSQL> <localhost> <AdminServer> <[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <BEA1-050CCC6E57BB175B1571> <11d1def534ea1be0:3847d2ea:1471260b38f:-8000-0000000000000145> <1404762896694> <BEA-000000> <[weblogic.jdbc.wrapper.PreparedStatement_oracle_jdbc_driver_OraclePreparedStatementWrapper@3b48] setInt(1, 10)>
.
.
.
--> execução
####<07/07/2014 16h54min56s BRT> <Debug> <JDBCSQL> <localhost> <AdminServer> <[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <BEA1-050CCC6E57BB175B1571> <11d1def534ea1be0:3847d2ea:1471260b38f:-8000-0000000000000145> <1404762896694> <BEA-000000> <[weblogic.jdbc.wrapper.PreparedStatement_oracle_jdbc_driver_OraclePreparedStatementWrapper@3b48] executeQuery()>
.
.
.
--> tratando retorno
####<07/07/2014 16h54min56s BRT> <Debug> <JDBCSQL> <localhost> <AdminServer> <[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <BEA1-050CCC6E57BB175B1571> <11d1def534ea1be0:3847d2ea:1471260b38f:-8000-0000000000000145> <1404762896698> <BEA-000000> <[weblogic.jdbc.wrapper.ResultSet_oracle_jdbc_driver_OracleResultSetImpl@3b49] getString(2)>
####<07/07/2014 16h54min56s BRT> <Debug> <JDBCSQL> <localhost> <AdminServer> <[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <BEA1-050CCC6E57BB175B1571> <11d1def534ea1be0:3847d2ea:1471260b38f:-8000-0000000000000145> <1404762896698> <BEA-000000> <[weblogic.jdbc.wrapper.ResultSet_oracle_jdbc_driver_OracleResultSetImpl@3b49] getString returns Administration


Em <DOMAIN_HOME>/servers/AdminServer/logs/AdminServer-diagnostic.log:

[2014-07-09T12:31:49.431-03:00] [AdminServer] [TRACE] [] [oracle.soa.adapter] [tid: [ACTIVE].ExecuteThread: '7' for queue: 'weblogic.kernel.Default (self-tuning)'] [userId: <anonymous>] [ecid: 11d1def534ea1be0:-559a5b:1471b88e265:-8000-000000000000163a,0:2] [SRC_CLASS: oracle.integration.platform.blocks.adapter.fw.log.LogManagerImpl] [WEBSERVICE_PORT.name: DepartmentPort] [APP: soa-infra] [composite_name: HRProject] [component_name: HRMediator] [component_instance_id: 24B6A1E0077E11E4BF9F99C63AA1D379] [J2EE_MODULE.name: fabric] [SRC_METHOD: log] [WEBSERVICE.name: HRMediator_ep] [J2EE_APP.name: soa-infra] [composite_instance_id: 1040020] Database Adapter  HRProject:SelectDepartmentById [ SelectDepartmentById_ptt::SelectDepartmentByIdSelect(SelectDepartmentByIdSelect_inputParameters,DepartmentsCollection) ]  <org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor basicExecuteCall> SELECT DEPARTMENT_ID, DEPARTMENT_NAME, MANAGER_ID, LOCATION_ID FROM DEPARTMENTS WHERE (DEPARTMENT_ID = ?)[[
    bind => [10]


]]

Nenhum comentário:

Postar um comentário