-->
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: How can I reduce the logging output to System.err?
PostPosted: Thu Jul 14, 2005 6:08 am 
Beginner
Beginner

Joined: Fri Apr 29, 2005 10:57 pm
Posts: 41
Hibernate version: 3

Normally I use Hibernate with web applications where I use log4j, and Hibernate doesn't give me any unneccessary output in that setting.

This time I had a project where I used Hibernate outside web context and wehre I didn't use log4j or any other logging library for that matter.

So now every time I .configure() Hibernate I get like 3 pages of output into my System.err which's mostly informative sutff, something I don't really care for.

Is there a way to turn this off or at least reduce the amount of text barfed out?

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 14, 2005 9:27 am 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
See 4.5. Logging in the reference manual.

HTH
Ernst


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 14, 2005 6:16 pm 
Beginner
Beginner

Joined: Fri Apr 29, 2005 10:57 pm
Posts: 41
Right, it tells me what categories there are if I'm planning to use JDK logging or log4j.

What if I don't want to use neither? I just want to use System.out and System.err...

And I'm running 1.5 so I guess I have JDK by default. So can I turn that extra logging off using JDK's logging api or something?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 15, 2005 1:56 am 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
see

http://java.sun.com/j2se/1.4.2/docs/api/java/util/logging/LogManager.html

and

http://java.sun.com/j2se/1.4.2/docs/guide/util/logging/overview.html

for more infos.

As a starting point
Quote:
By default, the LogManager reads its initial configuration from a properties file "lib/logging.properties" in the JRE directory. If you edit that property file you can change the default logging configuration for all uses of that JRE.

In addition, the LogManager uses two optional system properties that allow more control over reading the initial configuration:

* "java.util.logging.config.class"
* "java.util.logging.config.file"

These two properties may be set via the Preferences API, or as command line property definitions to the "java" command, or as system property definitions passed to JNI_CreateJavaVM.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 15, 2005 2:03 am 
Beginner
Beginner

Joined: Fri Apr 29, 2005 10:57 pm
Posts: 41
This sounds overly complicated...

So what you're saying that in order for me to reduce the amount of unneccessary logging that log4j does, I have to set a system property which would modify the log file location, and then I'd have to create that file and edit it, somehow disabling those loggers?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 15, 2005 2:16 am 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
AFIAK that's the price you have to pay for a configurable logging.

If you're familiar with log4j why not just put the log4j.jar and don't log this stuff config file into your classpath?

With jdk logging things are not realy more compiliated. Take the default logging.properties and change the line
Code:
.level= INFO

to
Code:
.level= OFF

and make the system property pointing to your new file.

HTH
Ernst


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 15, 2005 3:25 am 
Beginner
Beginner

Joined: Fri Apr 29, 2005 10:57 pm
Posts: 41
Well the reason I don't want to use log4j is because I'm being performance and memory conscious and I really don't need much logging in this project, so I don't want to waste extra space.

Thanks for the suggestion, I'll try it out.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 15, 2005 3:32 am 
Beginner
Beginner

Joined: Fri Apr 29, 2005 10:57 pm
Posts: 41
Ok I don't think it worked...

I did this:

// Custom JDK logging file
System.setProperty("java.util.logging.config.file",getAppRoot()+"/conf/logging.properties");

And I set that line to "FINER"

Yet I still see all the HIbernate garbage in my log.


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.