Remove cache logging with JBoss - java

I'm working on JBoss EAP 6.3 and in my server.log file, there is all the time the following logs :
10:22:33,525 DEBUG [org.hibernate.cache.spi.UpdateTimestampsCache]
(http-/0.0.0.0:8080-70) Pre-invalidating space [users], timestamp:
15507410135
10:22:33,526 DEBUG
[org.hibernate.cache.spi.UpdateTimestampsCache]
(http-/0.0.0.0:8080-70) Invalidating space [users], timestamp:
15507409535
10:22:33,842 DEBUG
[org.hibernate.cache.spi.UpdateTimestampsCache]
(http-/0.0.0.0:8080-50) Pre-invalidating space [users], timestamp:
15507410138
10:22:33,844 DEBUG
[org.hibernate.cache.spi.UpdateTimestampsCache]
(http-/0.0.0.0:8080-50) Invalidating space [users], timestamp:
15507409538
How can i remove these logs ?

In your case, the logging level for hibernate cache is set to debug. Setting logging level to info means that only log event at info or higher levels are logged.
You can change the logging level with the web console or by using CLI. An example CLI command would look like:
/subsystem=logging/logger=org.hibernate.cache:add(level=INFO)
If you're including Hibernate in your deployment and you have a log4j.properties consider the following.
log4j.properties
log4j.logger.org.hibernate.cache=info
or
log4j.xml file
<logger name="org.hibernate.cache">
<level value="info"/>
</logger>

Related

remove hibernate logging from Dropwizard app logs

I see a lot of logs logging al the queries that make the logs not very useful. I am trying to remove this logging from my dropwizard app logs I tried to do it through the yml file
logging:
level: "DEBUG"
loggers:
org.hibernate: ERROR
And also in the logback.xml
<logger name="org.hibernate">
<level value="ERROR" />
</logger>
I also tried appenders to the yml file as console and syslog. What is the way to remove these SELECT statements from the logs?
I dont want to move the logs to another file as I do want to see the errors
The logger isnt org.hibernate but I only see "Hibernate: select * FROM ....."
You should try changing your default application logging level to INFO instead
logging:
level: INFO
and further, modify log level of a package using
# Sets the level for 'org.hibernate' to ERROR
loggers:
org.hibernate: ERROR
Here is an effective example of the usage from dropwizard itself.
Or in your case probably the package contributing to the logs as
loggers:
org.hibernate.SQL: ERROR # note - not moving to another file either
You have to set hibernate.show_sql to false
database:
properties:
hibernate.show_sql: false
However, this alone may not work. I upvoted the other answer as it led me to this - you do indeed have to pay attention to your configured logging levels for the hibernate package because surprisingly, if your org.hibernate.SQL logging level is set to DEBUG then this will override the hibernate.show_sql: false config and log the SQL anyway!
You need to make sure it's set to INFO or greater
logging:
loggers:
"org.hibernate.SQL":
level: INFO
In my case, setting the "hibernate engine" level (in the application.yaml file) decreased the number of log messages:
loggers:
org.hibernate.engine: error

Disable jboss server log files

I have using simple web application which is hosted in Linux VM on jboss-eap-6.2. Application works fine.
Since My VM is containing very small amount of space I was trying reduce unnecessary log files. For me info log is very much sufficient and
You see there will be always server logs will be inherited automatically when server starts up. Here as follow in server path :
opt/gnrtestbed/jboss-eap-6.4/standalone/log>
-rw-r--r-- 1 gnrtb gnrtestbed 1864 Mar 7 07:40 gc.log.0.current
-rw-r--r-- 1 gnrtb gnrtestbed 14770464 Mar 7 07:40 server.log
so on so
And I don’t want any log details like console, boot,...etc.
I want to control the jboss log server in manner that I can only produce the log which I want.. For me just info which logged/coded in application is more than enough since its very small application
I have searched long in online and many suggested to disable the logs like below through add these lines to standalone.xml or domain.xml:
<system-properties>
<property name="org.jboss.as.logging.per-deployment" value="false"/>
</system-properties>
This above is also not helping. After adding this lines unable to start the server and end up in errors
so on so
And also, I have tried all the commenting stuffs inside of logging.properties file under path :
/opt/gnrtestbed/jboss-eap-6.4/standalone/configuration>
But I couldn’t stop the console,.. server logs… its just keep pouring...
Please let me know what I am missing or what I have to do further to avoid default server logs. Your help will be appreciated. Thanks
For your detailed understanding let me share my logging properties file as follow :
# Note this file has been generated and will be overwritten if a
# logging subsystem has been defined in the XML configuration.
# Additional loggers to configure (the root logger is always configured)
loggers=sun.rmi,jacorb,org.jboss.as.config,jacorb.config,org.apache.tomcat.util.modeler,com.arjuna,System.out
logger.level=TRACE
logger.handlers=FILE,CONSOLE
logger.sun.rmi.level=WARN
logger.sun.rmi.useParentHandlers=true
logger.jacorb.level=WARN
logger.jacorb.useParentHandlers=true
logger.org.jboss.as.config.level=DEBUG
logger.org.jboss.as.config.useParentHandlers=true
logger.jacorb.config.level=ERROR
logger.jacorb.config.useParentHandlers=true
logger.org.apache.tomcat.util.modeler.level=WARN
logger.org.apache.tomcat.util.modeler.useParentHandlers=true
logger.com.arjuna.level=WARN
logger.com.arjuna.useParentHandlers=true
logger.System.out.level=WARN
logger.System.out.useParentHandlers=true
handler.CONSOLE=org.jboss.logmanager.handlers.ConsoleHandler
handler.CONSOLE.level=WARN
handler.CONSOLE.formatter=CONSOLE
handler.CONSOLE.properties=enabled,autoFlush,target
handler.CONSOLE.enabled=true
handler.CONSOLE.autoFlush=true
handler.CONSOLE.target=SYSTEM_OUT
handler.FILE=org.jboss.logmanager.handlers.PeriodicRotatingFileHandler
handler.FILE.level=ALL
handler.FILE.formatter=FILE
handler.FILE.properties=append,autoFlush,enabled,suffix,fileName
handler.FILE.append=true
handler.FILE.autoFlush=true
handler.FILE.enabled=true
handler.FILE.suffix=.yyyy-MM-dd
handler.FILE.fileName=/opt/gnrtestbed/jboss-eap-6.4/standalone/log/server.log
formatter.CONSOLE=org.jboss.logmanager.formatters.PatternFormatter
formatter.CONSOLE.properties=pattern
formatter.CONSOLE.constructorProperties=pattern
formatter.CONSOLE.pattern=%K{level}%d{HH\:mm\:ss,SSS} %-5p [%c] (%t) %s%E%n
formatter.FILE=org.jboss.logmanager.formatters.PatternFormatter
formatter.FILE.properties=pattern
formatter.FILE.constructorProperties=pattern
formatter.FILE.pattern=%d{HH\:mm\:ss,SSS} %-5p [%c] (%t) %s%E%n

Logging Spring bean initialization with Log4J

When I run my application, it stops when beans are initializing but doesn't show any logs entries. So I don't know what happened:
Log4j.properties
log4j.rootLogger=DEBUG, stdout, R
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
org.springframework=DEBUG
org.springframework.beans.factory.support=DEBUG
log4j.logger.org.springframework.beans.factory.support=DEBUG
log4j.logger.org.springframework.beans=DEBUG
log4j.category.org.springframework.beans.factory=DEBUG
log4j.logger.org.springframework=DEBUG
log4j.logger.org.hibernate.hql.ast.AST=info
log4j.logger.org.hibernate.tool.hbm2ddl=warn
log4j.logger.org.hibernate.cache=info
log4j.logger.org.hibernate.jdbc=debug
log4j.logger.org.hibernate.type=trace
log4j.additivity.org.hibernate.SQL=false
log4j.logger.org.hibernate.transaction=debug
log4j.logger.java.sql.Statement=DEBUG
log4j.appender.stdout.layout.ConversionPattern=%d %t %C{1}- %m%n
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=${log4j.appender.R.File}
log4j.appender.R.MaxFileSize=2MB
log4j.appender.R.MaxBackupIndex=0
log4j.appender.R.Append=true
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d %t (%l) - %m%n
I want to get something like:
"BeanName" initialized
"BeanName" initialized
etc...
So then I would know where the initialization stopped. Is it possible to get such an output in the logs, when beans are initializing?
You need to set "org.springframework.beans.factory.support.DefaultListableBeanFactory" to debug level. The output looks something like this:
... - Creating instance of bean ...
... - Finished creating instance of bean ...
Update:
Add this to log4j.properties:
log4j.logger.org.springframework.beans.factory.support.DefaultListableBeanFactory=DEBUG
Keep in mind that Spring is using the commons-logging framework, therefore these lines will not appear in your Log4J logs. To redirect them use SLF4J. Add slf4j-api.jar, jcl-over-slf4j.jar, slf4j-log4j12.jar and log4j.jar to your lib directory and remove commons-logging.jar from it.
add to your log4j xml (check if you already have one with lavel ERROR, change it either INFO or DEBUG
<logger name="org.springframework">
<level value="INFO" />
</logger>

Hibernate GWT: Turn off hibernate logging to console

I've searched a lot of topics in the internet with similar problems, but any can help me to solve this problem. So I'm using GWT + Hibernate (jars):
junit-4.11-beta-1.jar
mysql-connector-java-5.1.22-bin.jar
dom4j-1.6.1.jar
antlr-2.7.7.jar
hibernate-commons-annotations-4.0.1.Final.jar
hibernate-core-4.1.8.Final.jar
hibernate-jpa-2.0-api-1.0.1.Final.jar
javassist-3.15.0-GA.jar
jboss-logging-3.1.0.GA.jar
jboss-transaction-api_1.1_spec-1.0.0.Final.jar
gwt-servlet.jar
hibernate-validator-4.0.2.GA.jar
validation-api-1.0.0.GA.jar
and all I want to do is disable console output like for example:
2012-12-14 23:41:09 org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: HHH000126: Indexes: [primary]
2012-12-14 23:41:09 org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: HHH000232: Schema update complete
cause it makes my app very slow. How can i do that?
The question has no relation to GWT. The impact of performance by these logs is Zero.
If you need to turn off your hibernate logs then you need to first find how you hibernate is being initialized and then address the log level for hibernate either there or in you applications log setup. Reference .
1) In code via some Annotation
2) from a hibernate properties file
3) from hibernate.cfg.xml
4) from log4j.properties
We use hibernate.cfg.xml and turn off hibernate sql logs using
<property name="show_sql">false</property>
You need to find somethign similar for your application.
In your log4j configuration set hibernate logger to higher level:
<logger name="org.hibernate">
<level value="error"/>
</logger>
If you don't want to see info level hibernate messages.

Tomcat 6 Log4j Configuration - stdout still being written to?

I have followed the directions to configure tomcat 6 to log using log4j from here: Logging in Tomcat
However, I have noticed that threads appear to be logging to stdout, with no regard to the log level set in log4j.properties. Here is my log4j.properties file:
log4j.rootLogger=WARN, CATALINA
# Define all the appenders
log4j.appender.CATALINA=org.apache.log4j.DailyRollingFileAppender
log4j.appender.CATALINA.file=${catalina.base}/logs/tomcat.out
log4j.appender.CATALINA.encoding=UTF-8
# Roll-over the log once per day
log4j.appender.CATALINA.DatePattern='.'yyyy-MM-dd'.log'
log4j.appender.CATALINA.layout.ConversionPattern = %d [%t] %-5p %c- %m%n
log4j.appender.CATALINA.layout=org.apache.log4j.PatternLayout
log4j.appender.CATALINA.append=true
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.encoding=UTF-8
log4j.appender.CONSOLE.conversionPattern = %d [%t] %-5p %c- %m%n
# Configure which loggers log to which appenders
#log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost]=INFO, LOCALHOST
#log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager]=INFO, MANAGER
#log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager]=INFO, HOST-MANAGER
log4j.logger.org.hibernate.hql.ast=ERROR
This is the file that's in my ${CATALINA_BASE}/lib directory. Notice the last line where I set org.hibernate.hql.ast level to ERROR. The following is constantly being spewed into my tomcat.out log:
15663118 [http-8080-1] WARN org.hibernate.hql.ast.QueryTranslatorImpl - firstResult/maxResults specified with collection fetch; applying in memory!
15663531 [TP-Processor7] WARN org.hibernate.hql.ast.QueryTranslatorImpl - firstResult/maxResults specified with collection fetch; applying in memor
62100 [http-8080-18] INFO org.hibernate.cache.StandardQueryCache - starting query cache at region: video
I have a similar log4j.properties file deployed in my webapp under WEB-INF/classes that have similar properties (but logs to a different file). How come the log statements do not follow the conversion pattern I have defined, nor follow the log level limit I set?
I'm running tomcat 6.0.30, Java 1.6.0_23, and log4j 1.2.16 on SunOS 5.10 amd64. The output to my application log works as expected. Thanks in advance for your help.
Andrew
The main problem here is that you're using the old properties file -style way of configuring Log4J. Because most people use XML configuration method these days, you'll be hard pressed to find anyone who can answer the question.
However, what you need to do is to set threshold for each appender. This is how it's done in XML:
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
...
<param name="Target" value="System.out"/>
<param name="Threshold" value="WARN"/>
...
</appender>
It might look like his on flat file:
log4j.appender.Console.Threshold=WARN

Categories