1

I am using ANT SCRIPT to generate POJO classes from database. I want to generate log for each class and table while executing the script. Can I use Log4J for Hibernate? Any documentation or tutorial for this? or any other suggestions? Please help!!

Thanks in advance.

3 Answers 3

2

just add to your hibernate.cfg.xml with following.

<property name="hibernate.show_sql">true</property>
Sign up to request clarification or add additional context in comments.

Comments

2

Just write this code in your hibernate.cfg.xml

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

This will show hql on catalina.out file. or on console if you are making desktop application.

4 Comments

Yes! You are right but I want to generate at the time of execution of ANT SCRIPT. i.e. while building ant script. Thanks for response.
when u execute ant script classes are being generated..??
I think query is generated when hibernate.cfg.xml is called. And For web application it is generated when tomcat is started. And for desktop application you have to run that class which is calling hibernate.cfg.xml
We have build_hibernate.xml. What we do is Just right click on this file in Eclipse. And "Run As >>>>> Ant Script". It has nothing to do with tomcat execution. If you dont know anything about ANT SCRIPT. You can refer to its documentation. Thanks.
1

You can use Log4J as log listener for Ant, then Log4J will log any ant message or call. Use this argument to attach the listener during ant execution.

-listener "org.apache.tools.ant.listener.Log4jListener"

Of course you'll have to specify the logger in the ant classpath.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.