-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 
Author Message
 Post subject: Display query parameters in console
PostPosted: Tue Feb 10, 2009 11:48 pm 
Newbie

Joined: Tue Feb 10, 2009 11:37 pm
Posts: 4
Hi Good Morning everybody

In my hibernate.cfg.xml file I wrote like

<property name="hibernate.show_sql">true</property>
<property name="format_sql">true</property>
<property name="hibernate.use_sql_comments">true</property>


in console I am able to get sql query,sql format & comments like


/* insert com.abc.xyz.MyClass
*/ insert
into
my_table
(np_pk, ct_pk, title_uni, action, layout, view_order, title_Font, icon_url, image_url, link, sub_key, created_on, last_modified_on, created_by, published_by, state, breakingnews_id, pk)
values
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)

but I would like to see the parameters ,plz help me how can display the parameters in console



Thanks a lot in advance
Shaik Vali.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 11, 2009 12:43 am 
Expert
Expert

Joined: Fri Jan 30, 2009 1:47 am
Posts: 292
Location: Bangalore, India
You will have to configure log4j for tht. Add the following categories to log4j.xml
Code:
   <category name="org.hibernate.SQL">
       <priority value="TRACE"/>
       <appender-ref ref="CONSOLE"/>
   </category>

   <category name="org.hibernate.type">
       <priority value="TRACE"/>
       <appender-ref ref="CONSOLE"/>
   </category>

_________________
Regards,
Litty Preeth


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 11, 2009 2:48 am 
Newbie

Joined: Tue Feb 10, 2009 11:37 pm
Posts: 4
Hi littypreethkr many thanks for your reply , instead of log4j.xml I need

in log4j.properties . Could you please help me out.


Thanks a lot
Shaik Vali


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 11, 2009 3:03 am 
Expert
Expert

Joined: Fri Jan 30, 2009 1:47 am
Posts: 292
Location: Bangalore, India
Well, I am not a log4J expert. Still try adding the following to ur log4j.properties:
Code:
log4j.appender.STDOUT=org.apache.log4j.ConsoleAppender
log4j.appender.STDOUT.layout=org.apache.log4j.PatternLayout
log4j.appender.STDOUT.layout.ConversionPattern=%d %p [%t] %C{1} - %m\n

log4j.category.org.hibernate.SQL=TRACE, STDOUT
log4j.category.org.hibernate.type=TRACE, STDOUT

Plz lemme know if it works.

_________________
Regards,
Litty Preeth


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 11, 2009 3:41 am 
Newbie

Joined: Tue Feb 10, 2009 11:37 pm
Posts: 4
Hi , I was trying to write the logs in to sepate file like


log4j.appender.STDOUT=org.apache.log4j.RollingFileAppender
log4j.appender.STDOUT.Threshold = WARN
log4j.appender.STDOUT.File=C:\\Logs\\Licence.log
log4j.appender.STDOUT.MaxFileSize=10MB
log4j.appender.STDOUT.MaxBackupIndex=5
log4j.appender.STDOUT.layout=org.apache.log4j.PatternLayout
log4j.appender.STDOUT.layout.ConversionPattern=%d{ISO8601} %-5p [%F:%L] : %m%n

log4j.category.org.hibernate.SQL=TRACE, STDOUT
log4j.category.org.hibernate.type=TRACE, STDOUT

It's not writing to log file.
could you please helpme how can I write ..
please correct me.

Thanks a lot.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2009 6:07 am 
Expert
Expert

Joined: Fri Jan 30, 2009 1:47 am
Posts: 292
Location: Bangalore, India
Put
log4j.appender.STDOUT.Threshold = TRACE

You have put it as WARN

_________________
Regards,
Litty Preeth


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2009 8:47 am 
Newbie

Joined: Tue Feb 10, 2009 11:37 pm
Posts: 4
Hi littypreethkr ,

it's working fine .... thanks a lot.


Top
 Profile  
 
 Post subject: Re: Need Help
PostPosted: Wed Mar 10, 2010 5:41 pm 
Newbie

Joined: Wed Mar 10, 2010 5:35 pm
Posts: 1
littypreethkr wrote:
Put
log4j.appender.STDOUT.Threshold = TRACE

You have put it as WARN


I would like to see the parameters ,plz help me how can display the parameters in console. I am using log4j.properties

### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5p %c %x - %m%n
### direct log message to eligibility.log file ###
log4j.appender.eligibility=org.apache.log4j.RollingFileAppender
log4j.appender.eligibility.file=svcs/logs/server.log
log4j.appender.eligibility.MaxFileSize=100KB
log4j.appender.eligibility.MaxBackupIndex=5
log4j.appender.eligibility.layout=org.apache.log4j.PatternLayout
log4j.appender.eligibility.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5p %c %x - %m%n
### root logger option ###
log4j.rootLogger=error, stdout
### Hibernate logging options ###
log4j.logger.net.sf.hibernate=error
### log JDBC bind parameters ###
log4j.logger.net.sf.hibernate.type=error
### log PreparedStatement cache activity ###
log4j.logger.net.sf.hibernate.ps.PreparedStatementCache=error
## added by me to get the values instead of ('?'?'?') these parameters
log4j.appender.STDOUT.Threshold=TRACE
log4j.category.org.hibernate.SQL=TRACE, STDOUT
log4j.category.org.hibernate.type=TRACE, STDOUT

Thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.