开发者

hibernate logging

I have an interface that I want Hibernate to log everything to. My curernt configuration is done programmatically, so I don't have any hibernate.properties or hibernate.cfg.xml file.

configuration = new Configuration()  
.setProperty( "hibernate.connection.driver_class", "org.postgresql.Driver" )
.setProperty( "hibernate.dialect","org.hibernate.dialect.PostgreSQLDialect")
.setProperty( "hibernate.connection.url", "jdbc:postgresql://****:5483/postgres")
.setProperty( "hibernate.connection.username", "****")
.setProperty( "hibernate.connection.password", "****")
.setProperty( "hibernate.c3p0.min_size"," 5")
.setProperty( "hibernate.c3p0.max_size"," 20")
.setProperty( "hibernate.c3p0.timeout"," 1800")
.setProperty( "hibernate.c3p0.max_statements"," 50")
.setProperty( "hibernate.connection.pool_size", "1" )
.setProperty( "hibernate.current_session_context_class", "thread")
.setProperty( "hibernatecache.provider_class", "or开发者_如何转开发g.hibernate.cache.NoCacheProvider")
.setProperty( "hibernate.show_sql", "true" )
.addAnnotatedClass( ... )
.addAnnotatedClass( ... )
;

I have a logging interface which has a method

public void logLine( String line );

How can I

1) specify what is logged

2) redirect the logs to the interface?


Hibernate is logging output to the stdout. You'll have to somehow intercept it and redirect to your logging mechanism.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜