Change Loglevel for sqlite4java

989 views
Skip to first unread message

derdickemax

unread,
Aug 19, 2011, 11:07:40 AM8/19/11
to sqlite4java
I am trying to silence sqlj4java.

I have created a log4j.properties in the Classpath:

log4j.rootLogger=WARN, S
log4j.appender.S = org.apache.log4j.ConsoleAppender
log4j.appender.S.layout = org.apache.log4j.PatternLayout
log4j.appender.S.layout.ConversionPattern = %d{HH:mm:ss} %c{1} [%p] %m
%n
log4j.logger.com.almworks.sqlite4java=SEVERE

And I use a Bootstrap-class to do:

Logger.getLogger("com.almworks.sqlite4java").setLevel(Level.SEVERE);

But I still do get INFO-messages from sqlite4java:

PUTZFRAU SETS LOGLEVEL TO WARNING
PUTZFRAU WILL DISABLE play.db.DBPlugin@1493102
PUTZFRAU WILL DISABLE play.jobs.JobsPlugin@18488ef
19.08.2011 17:02:33 com.almworks.sqlite4java.Internal log
INFO: [sqlite] DB[1]: instantiated [app3.db]
19.08.2011 17:02:33 com.almworks.sqlite4java.Internal log
INFO: [sqlite] Internal: loaded sqlite4java-linux-i386 from /home/max/
Bastelei/Play_Framework/app3/lib/libsqlite4java-linux-i386.so
19.08.2011 17:02:33 com.almworks.sqlite4java.Internal log
INFO: [sqlite] Internal: loaded sqlite 3.7.4, wrapper 0.2
19.08.2011 17:02:33 com.almworks.sqlite4java.Internal log
INFO: [sqlite] DB[1]: opened
19.08.2011 17:02:33 com.almworks.sqlite4java.Internal log
INFO: [sqlite] DB[1]: connection closed

How can I silence the INFO-Messages???

Thank You!

Igor Sereda

unread,
Aug 19, 2011, 6:25:31 PM8/19/11
to sqlite4java
One thing I'd check is whether the line with setLevel() in your call
really gets called. Or place it just before you create an
SQLiteConnection.

sqlite4java uses java.util.logging.Logger, so log4j configuration must
not be relevant. I believe "Logger" in your code is not log4j, right?

Hope this helps!
Igor

derdickemax

unread,
Aug 23, 2011, 4:01:44 AM8/23/11
to sqlite4java
Privet, Igor!

Sorry for eating up Your time.
I know this is not directly a sqlite4java issue.
The strange thing is that I define the log format in my custom
log4j.properties as:
log4j.appender.S.layout.ConversionPattern = %d{HH:mm:ss} %c{1} [%p] %m
%n
to the german date-time format and I can see the result:

23.08.2011 09:31:27 com.almworks.sqlite4java.Internal log
INFO: [sqlite] DB[1]: connection closed

So my log4j.properties is definitively processed!
But the log level is still INFO.

I even changed the system property:

System.out.println("PUTZFRAU SETS SQLITE4JAVA DEBUG TO 'FALSE'");
System.setProperty("sqlite4java.debug","false");

because this is used in Internal.loadLibraryX() - but didn't help.

The last alternative is to make a custom build and add a hardcoded
Level.WARN to it.

Igor Sereda

unread,
Aug 23, 2011, 2:33:52 PM8/23/11
to sqlite4java
sqlite4java does not use log4j, it uses java.util.logging.

You need to run this line before the first call to sqlite4java:

java.util.logging.Logger.getLogger("com.almworks.sqlite4java").setLevel(java.util.logging.Level.WARNING);

You can use OFF instead of WARNING to turn the logging completely.

Hope this helps!

Kind regards,
Igor

mail...@gmail.com

unread,
Mar 29, 2014, 5:29:22 AM3/29/14
to sqlit...@googlegroups.com, ser...@almworks.com
It's strange, but it's not working for me.

I placed :
java.util.logging.Logger.getLogger("com.almworks.sqlite4java").setLevel(java.util.logging.Level.OFF);

into public static void main(String args[]) method and nothing was changed in the log - there are still many informative lines in the log.
Maybe I must do it the other way?


вторник, 23 августа 2011 г., 22:33:52 UTC+4 пользователь Igor Sereda написал:

mail...@gmail.com

unread,
Mar 29, 2014, 5:37:36 AM3/29/14
to sqlit...@googlegroups.com, ser...@almworks.com
Oh! But when I put this line right befor creating the connection - it works fine!

Thank you!




вторник, 23 августа 2011 г., 22:33:52 UTC+4 пользователь Igor Sereda написал:
sqlite4java does not use log4j, it uses java.util.logging.

victor....@gmail.com

unread,
Oct 17, 2014, 12:41:34 PM10/17/14
to sqlit...@googlegroups.com, ser...@almworks.com, mail...@gmail.com
Some thoughts about log4j and java.util.logging.

It is not working:

   protected final static Logger log = Logger.getLogger(Some.class);

   public static void main(String[] args) {
     
java.util.logging.Logger.getLogger("com.almworks.sqlite4java").setLevel(Level.OFF);
     
PropertyConfigurator.configure("log4j.properties");

     
...
   
}



It is working:

   protected final static Log4JLoggerWrapper log;

   
static {
      java
.util.logging.Logger.getLogger("com.almworks.sqlite4java").setLevel(Level.OFF);
      log
= Logger.getLogger(Some.class);
   
}

   
public static void main(String[] args) {
     
PropertyConfigurator.configure("log4j.properties");

     
...
   
}



суббота, 29 марта 2014 г., 15:37:36 UTC+6 пользователь mail...@gmail.com написал:
Reply all
Reply to author
Forward
0 new messages