We would like to trace all activity on org.hibernate.type
category post application startup, since we would like to avoid all trac开发者_StackOverflowe logs during application startup time (as it takes a long time).
Note: Currently jboss6/server/default/deploy/jboss-logging.xml
contains a TRACE
for org.hibernate.type
category.
Is it possible to enable this post startup in a programmatic fashion?
Write a POJO to check the status of JBoss server - whether it's started or not. You can tap into MBean: jboss.system:type=Server and inspect boolean property Started. If it's started, dynamically change the loggin level for Hibernate using something like this:
Logger hibernate = (Logger)LoggerFactory.getLogger(<logger name>);
hibernate.setLevel(Level.TRACE);
Now you can bundle this POJO with your application archive and schedule it as a quartz job to trigger after a minute or so. When the POJO has done it's job, cancel its subsequent scheduling.
If you don't want to schedule it as a quartz job, you could deploy this a separate artifact under deploy.last folder and let it change the logging level right away without checking the JBoss server status.
精彩评论