How to disable default logging

1,300 views
Skip to first unread message

bala

unread,
Jun 9, 2012, 3:01:57 PM6/9/12
to res...@googlegroups.com
Hi There,

  Im having trouble disabling info logs that gets printed in console. my current configuration is using log4j. is there any way to disable logging using log4j or any other option. logging is causing a lot of performance issue when dealing with large volumes of data. please help. appreciate your very much.

Thank you,
Bala.

Marcel Stör

unread,
Jun 10, 2012, 1:31:56 AM6/10/12
to res...@googlegroups.com
It's certainly possible. You know
http://restfb.com/#fetching-single-objects -> logging? I suppose so...
Then in log4j.xml you need to change the level for com.restfb loggers,
something like
<logger name="com.restfb" additivity="false">
<level value="WARN" />
<appender-ref ref="<whichever-appender-you-use>" />
</logger>

Cheers,
Marcel

--
Marcel Stör, http://www.frightanic.com
Couchsurfing: http://www.couchsurfing.com/people/marcelstoer
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

bala

unread,
Jun 10, 2012, 2:06:44 AM6/10/12
to res...@googlegroups.com
Hi Marcel,

  Thank you for the reply. but its not working. i have set the log level to ERROR but im still noticing the INFO logs in my console.  

  eg: 'INFO: Facebook responded with HTTP status code 200 and response body: '

  <logger name="com.restfb" additivity="false"> 
   <level value="ERROR" /> 
   <appender-ref ref="console" /> 
</logger> 

Thank you,
bala.

bala

unread,
Jun 10, 2012, 4:28:04 AM6/10/12
to res...@googlegroups.com
Its working. thank you for all the help. i missed jvm param from example earlier.
  
-bala.

Sam

unread,
Nov 27, 2012, 12:06:02 AM11/27/12
to res...@googlegroups.com
Looks like I am doing something wrong as I am not able to disable logging.

This is my log4j.properties file.

# Direct log messages to a log file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=C\:\\L ogging\\logging.log
log4j.appender.file.MaxFileSize=1MB
log4j.appender.file.MaxBackupIndex=1
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
 
# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
 
log4j.category.com.restfb=WARN,file
log4j.additivity.com.restfb=false
# Root logger option
log4j.rootLogger=WARN, file

Mark Allen

unread,
Nov 27, 2012, 4:04:01 PM11/27/12
to res...@googlegroups.com
RestFB uses java.util.logging, it looks like you are using log4j.  You can bridge java.util.logging to log4j using slf4j, see http://restfb.com for details.  Unfortunately Java logging will be a mess for quite a while yet.

Thanks
Mark

Volodymyr Dvornyk

unread,
Nov 27, 2012, 5:36:27 PM11/27/12
to res...@googlegroups.com
You can easy make this in 3 steps 
1  add dependencies to your maven 
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
<version>1.6.6</version>
</dependency>
2 Change the main handler in logging.properties:
  1. handlers=org.slf4j.bridge.SLF4JBridgeHandler
  2.  3 Point JULI at the logging.properties file with -Djava.util.logging.config.file=path/to/logging.properties or disable via SLF4JBridgeHandler.removeHandlersForRootLogger(); // (since SLF4J 1.6.5)
            


2012/11/27 Mark Allen <m...@xmog.com>
Reply all
Reply to author
Forward
0 new messages