I'm using Hibernate for a personal project.
In my project, I have these directory:
+ conf
log4j.properties
+ bin
my classes
Using Windows console, I go to project directory (the parent of bin and conf) and I start the application with a command like this:
java -cp conf;lib/lib1.jar;lib/lib2.jar;[etc] com.moc.Main
My log4j.properties file is this (taken from an hibernate example):
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 - %m%n
log4j.rootLogger=info, stdout
log4j.logger.org.hibernate=error
log4j.logger.org.hibernate.tool.hbm2ddl=error
log4j.logger.org.hibernate.hql.ast.QueryTranslatorImpl=error
log4j.logger.org.hibernate.hql.ast.HqlSqlWalker=error
log4j.logger.org.hibernate.hql.ast.SqlGenerator=error
log4j.logger.org.hibernate.hql.ast.AST=error
On application start, this is the output:
2010-11-06 19:00:56,376 - Logger.getRootLogger().info() statement
12 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.5.3-Final
13 [main] INFO org.hibernate.cfg.Environment - hibernate.properties not found
16 [main] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
20 [main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
108 [main] INFO org.hibernate.cfg.Configuration - configuring from resource: com/moc/hibernate.cfg.xml
108 [main] INFO org.hibernate.cfg.Configuration - Configuration resource: com/moc/hibernate.cfg.xml
124 [main] INFO org.hibernate.cfg.Configuration - Reading mappings from file: conf\hiber\Customer.hbm.xml
.
.
.
and so on
.
.
.
795 [main] INFO org.hibernate.impl.SessionFactoryImpl - closing
795 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider - cleaning up connection pool: jdbc:mysql://localhost/mydb
The color of Hibernate log lines is red, my log lines are black.
Why I still see INFO output from Hibernate? What am I doing wrong?
A good way of checking your log4j configuration and the events occuring at runtime is adding
-Dlog4j.debug option to the java command line. In your case it will become:
java -Dlog4j.debug -cp conf;lib/lib1.jar;lib/lib2.jar;[etc] com.moc.Main
This will throw information on console of the sequence of loading of log4j configuration. You can then determine if your log4j.properties is getting loaded correctly or not.
Your log4j configuration looks ok, is your log4j.properties file on the classpath and in the root package? I.e. is it in the root of conf, lib1.jar, lib2.jar pr any other jar/directory in your classpath?
Try this to check if the file is being loaded correctly.
On this line:
log4j.rootLogger=info, stdout
chage to
log4j.rootLogger=error, stdout
This will set the log level for the root logger and hence all loggers to ERROR, if you are still seeing the INFO log entries then your log4j.properties file must not be loading correctly, most likely for the reasons stated above.
Can you try this syntax instead?
log4j.category.org.hibernate=ERROR
Related
I am working on a project using Intellij IDEA Community, so I am using Jetty Runner to deploy my web application in localhost, everything is working ok, but I want to configure logs regarding Jetty, at server startup I see this kind of log :
14:50:20.516 [main] DEBUG o.eclipse.jetty.webapp.WebAppContext - isSystemResource==false org.springframework.expression.spel.ast.OpDec jar:file:/C:/Mario/development/spring/spring5/workspace/springsecurity/chapter02/chapter02.00-calendar/build/exploded/WEB-INF/lib/spring-expression-4.3.11.RELEASE.jar!/org/springframework/expression/spel/ast/OpDec.class
14:50:20.516 [main] DEBUG o.e.jetty.webapp.WebAppClassLoader - WAP webapp loaded class org.springframework.expression.spel.ast.OpDec
14:50:20.516 [main] DEBUG o.eclipse.jetty.webapp.WebAppContext - isSystemResource==false org.springframework.expression.spel.ast.OperatorNot jar:file:/C:/Mario/development/spring/spring5/workspace/springsecurity/chapter02/chapter02.00-calendar/build/exploded/WEB-INF/lib/spring-expression-4.3.11.RELEASE.jar!/org/springframework/expression/spel/ast/OperatorNot.class
14:50:20.517 [main] DEBUG o.e.jetty.webapp.WebAppClassLoader - WAP webapp loaded class org.springframework.expression.spel.ast.OperatorNot
1
I want to change the granularity from DEBUG to info regarding jetty server.
Put a jetty-logging.properties file in your resources folder and configure the logging there:
# Configure for System.err output
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog
# Configure StdErrLog to log all jetty namespace at default of WARN or above
org.eclipse.jetty.LEVEL=INFO
More info here: https://www.eclipse.org/jetty/documentation/9.4.x/configuring-logging.html
I'm connecting with Java to neo4j using the GraphDatabase.driver and I have this log4j.properties file which suppresses the output of HBase and MongoDB but doesn't work with neo4j:
log4j.rootLogger=OFF, 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{yy/MM/dd HH:mm:ss} %p %c{2}: %m%n
The logging output that shows up in the client application looks like this:
Mär 15, 2018 11:20:03 AM org.neo4j.driver.internal.logging.JULogger info
INFORMATION: Closing driver instance org.neo4j.driver.internal.InternalDriver#6743e411
Mär 15, 2018 11:20:03 AM org.neo4j.driver.internal.logging.JULogger info
INFORMATION: Closing connection pool towards localhost:7687
Mär 15, 2018 11:20:05 AM org.neo4j.driver.internal.logging.JULogger info
How can this be disabled?
The JULogger of the neo4j GraphDatabase.driver can be disabled using the java.util.logging.LogManager
LogManager.getLogManager().reset();
This will disable the logging, thus even suppress error messages. If just the INFO message shown in the example output should be suppressed then the log level has to be changed.
Logger rootLogger = LogManager.getLogManager().getLogger("");
rootLogger.setLevel(Level.SEVERE);
for (Handler h : rootLogger.getHandlers())
h.setLevel(Level.SEVERE);
<logger name="org.neo4j.ogm.drivers.http" level="WARN" additivity="false"></logger>
My Java7 project uses c3p0 (0.9.5.1) for connection pooling and Log4j (1.2.17) for logging. It seems that log4j logs c3p0 INFO logs in ERROR level:
2017-02-09T21:30:19.545+01:00 app_r41 jsvclog[5135] err: JSVC [MLog-Init-Reporter] INFO com.mchange.v2.log.MLog - MLog clients using slf4j logging.
2017-02-09T21:30:19.959+01:00 app_r41 jsvclog[5135] err: JSVC [main] INFO com.mchange.v2.c3p0.C3P0Registry - Initializing c3p0-0.9.5.1 [built 16-June-2015 00:06:36 -0700; debug? true; trace: 10]
2017-02-09T21:30:21.294+01:00 app_r41 jsvclog[5135] err: JSVC [main] INFO com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource - [configuration of ComboPooledDataSource follows here...]
Now this is confusing and I want to disable it.
This is the relevant part of my log4j.properties configuration:
log4j.rootLogger=INFO, SYSLOG_APPENDER
log4j.logger.com.mchange=WARN, SYSLOG_APPENDER
What am I missing?
Setting this system property during service start-up fixes the problem:
System.setProperty( "com.mchange.v2.log.Log4jMLog.DEFAULT_CUTOFF_LEVEL", "WARNING" );
I am working on java project and i am using standford corenlp http://stanfordnlp.github.io/CoreNLP/ library within it.
I have added them as reference library and also added some maven dependency. I have setup whole project with eclipse.
Now I create runnable jar for this project, but when I execute that jar it takes lot of time to execute library english.sutime.txt as follow,
[main] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator tokenize
[main] INFO edu.stanford.nlp.pipeline.TokenizerAnnotator - TokenizerAnnotator: No tokenizer type provided. Defaulting to PTBTokenizer.
[main] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator ssplit
[main] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator pos
Reading POS tagger model from edu/stanford/nlp/models/pos-tagger/english-left3words/english-left3words-distsim.tagger ... done [1.4 sec].
[main] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator lemma
[main] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator ner
Loading classifier from edu/stanford/nlp/models/ner/english.all.3class.distsim.crf.ser.gz ... done [1.9 sec].
Loading classifier from edu/stanford/nlp/models/ner/english.muc.7class.distsim.crf.ser.gz ... done [2.0 sec].
Loading classifier from edu/stanford/nlp/models/ner/english.conll.4class.distsim.crf.ser.gz ... done [2.6 sec].
[main] INFO edu.stanford.nlp.time.JollyDayHolidays - Initializing JollyDayHoliday for SUTime from classpath edu/stanford/nlp/models/sutime/jollyday/Holidays_sutime.xml as sutime.binder.1.
Reading TokensRegex rules from edu/stanford/nlp/models/sutime/defs.sutime.txt
Jun 29, 2016 6:37:39 PM edu.stanford.nlp.ling.tokensregex.CoreMapExpressionExtractor appendRules
INFO: Read 83 rules
Reading TokensRegex rules from edu/stanford/nlp/models/sutime/english.sutime.txt
Jun 29, 2016 6:58:03 PM edu.stanford.nlp.ling.tokensregex.CoreMapExpressionExtractor appendRules
INFO: Read 25 rules
[main] INFO edu.stanford.nlp.pipeline.StanfordCoreNLP - Adding annotator parse
[main] INFO edu.stanford.nlp.parser.common.ParserGrammar - Loading parser from serialized file edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz ...
done [3.1 sec].
So after english.sutime.txt I have to wait for further process about 15minutes. But project execute in eclipse not take this much time.
Can anyone help me to resolve this? My runnable jar contains all dependency within it.
Thanks,
Priyank
While creating the runnable jar file in eclipse, select "Extract Required libraries into generated jar" instead of "Package required libraries into generated jar".
I just switched my project from JUL (java.util.logging) to SL4J over JUL. Everything works great, I only have one grievance: when logging, the timestamps are not very relevant to me, for example:
2 [pool-2-thread-1] INFO com.lexit.server.ServerContext - Context initialized.
703 [pool-2-thread-1] INFO com.lexit.server.ServerContext - Connection with database succesful.
1144 [pool-2-thread-1] INFO com.lexit.server.ServerContext - External emails will be sent
1144 [pool-2-thread-1] INFO com.lexit.server.ServerContext - Alarms will be sent fr
1146 [pool-2-thread-1] INFO java.lang.Class - Adding reccuring timer with id: 1234567
How can I configure SL4J to have more relevant timestamps (e.g. 8-Mar-2012 5:38:00 PM)??
That's the logging format emitted by SLF4J's SimpleLogger.
See for yourself at:
http://www.slf4j.org/apidocs/org/slf4j/impl/SimpleLogger.html
SimpleLogger is the logger that gets used when you haven't added one of the SLF4J "bridge" jars to your classpath. Make sure you add slf4j-jdk14-x.x.x.jar (the JUL bridge) to your classpath, so that SLF4J will be configured to bridge to JUL.