Is there a way to silence hsqldb logging? - java

I have an embedded Hsqldb set up in my project. But it dumps a lot of info on the output when working, and I currently do not need that info:
Mar 29, 2012 10:18:11 PM org.hsqldb.persist.Logger logInfoEvent
INFO: Checkpoint start
Mar 29, 2012 10:18:11 PM org.hsqldb.persist.Logger logInfoEvent
INFO: checkpointClose start
Mar 29, 2012 10:18:11 PM org.hsqldb.persist.Logger logInfoEvent
INFO: checkpointClose end
Mar 29, 2012 10:18:11 PM org.hsqldb.persist.Logger logInfoEvent
INFO: Checkpoint end
Is there a way to silence that output?

Unfortunately, i don't believe so. we have the same issue in our project. i believe i checked the source at one point in time and concluded that hsqldb does not provide a way to influence this logging.
I stand corrected (as #fredt mentioned in his comment to the other answer), you can control this logging via the jdk log levels. setting the "hsqldb.db" log level to something like WARNING will suppress this output. you can do this using the logging.properties file or programmatically (after hsqldb loads) using something like Logger.getLogger("hsqldb.db").setLevel(Level.WARNING) (assuming you are using java util logging).
As noted in the comment below, hsqldb also resets the java logging configuration. If embedding it in another application, you may want to disable that functionality by setting the system property "hsqldb.reconfig_logging" to "false" (before hsqldb is loaded).

For anyone looking for a command line solution.
Start your app/server with a property pointing to the location of a dedicated properties file:
-Djava.util.logging.config.file=/location/of/your/hsqldblog.properties"
Which contains the following line to change Java logging for Hsqldb.
# Change hsqldb logging level
org.hsqldb.persist = WARNING
Side note, you can choose from the following levels:
SEVERE WARNING INFO CONFIG FINE FINER FINEST
More info on Java Logging

For Slf4j + Logback users:
Add log4j-over-slf4j as a dependency (don't forget to exclude original log4j dependency if you have any). If you use Gradle, add something like this into your build.gradle:
runtime group: 'org.slf4j', name: 'log4j-over-slf4j', version: '1.7.25'
Then, add this to your logback.xml:
<logger name="hsqldb.db" level="warn"/>

You can use setSilent(true) when starting server from code:
Server server = new Server();
server.setSilent(true);
server.setDatabaseName(0, "mainDb");
server.setDatabasePath(0, "mem:mainDb");
server.setPort(9001);
server.start();

Related

Tomcat 8.5 - Cache warning flood

I am trying to migrate from Tomcat 8.0.37 to 8.5.6
In this new version, the err console is flooded constantly with these warnings:
oct. 27, 2016 3:16:40 PM org.apache.catalina.webresources.Cache getResource
WARNING: Unable to add the resource at [/WEB-INF/lib/something.jar]
to the cache because there was insufficient free space available after evicting expired cache entries -
consider increasing the maximum size of the cache
I want to configure the servlet (web.xml or Spring) to ignore caching for some file types (*.jar)
I've read about configuring the context.xml file but it feels like a workaround the real issue.
how can I tell Tomcat to log everything to slf4j?
I added this to the manifest but it doesn't work :
Dependencies: org.slf4j
The cache warnings are caused by a known bug in 8.5.6 that will be fixed in 8.5.7. The new version should be available in a week or so.
If you want to use slf4j then following the slf4j instructions for redirecting java.util.logging output.

How do I turn off this logging?

How do I turn off this logging?
Log
Dec 03, 2013 1:23:21 PM com.google.appengine.datanucleus.MetaDataValidator validate
INFO: Performing appengine-specific metadata validation for com.mwv.pic.dto.Study
lib/logging.properties
.level=INFO
# Set the default logging level for ORM, specifically, to WARNING
DataNucleus.level=WARNING
com.google.appengine.datanucleus=WARNING
Run Configurations > Arguments > Program Arguments
-Djava.util.logging.config.file=file:lib/logging.properties
If I put -Djava.util.logging.config.file=file:lib/logging.properties in VM argument properties, then NOTHING will log!
I think that you will find that DataNucleus JDO (if indeed you are using JDO) depends on the logging technology Apache Log4J.
I use JDO and define DataNucleus Log4J settings in files called "log4j.properties": one for production and one for app building using NetBeans.

Removing the Logs in Java

I want To remove the logs which gets generated during runtime of code.
E.g i m using asterisk-java for voip/asterisk and I always got following messages
Jul 30, 2012 10:55:17 AM org.asteriskjava.manager.internal.ManagerConnectionImpl connect
INFO: Connecting to 192.168.0.27:5038
Jul 30, 2012 10:55:18 AM org.asteriskjava.manager.internal.ManagerConnectionImpl setProtocolIdentifier
INFO: Connected via Asterisk Call Manager/1.1
Jul 30, 2012 10:55:18 AM org.asteriskjava.manager.internal.ManagerConnectionImpl setProtocolIdentifier
WARNING: Unsupported protocol version 'Asterisk Call Manager/1.1'. Use at your own risk.
Jul 30, 2012 10:55:18 AM org.asteriskjava.manager.internal.ManagerConnectionImpl doLogin
INFO: Successfully logged in
Jul 30, 2012 10:55:22 AM org.asteriskjava.manager.internal.ManagerConnectionImpl doLogin
INFO: Determined Asterisk version: Asterisk 1.0
Is there any configuration setting or other way around to remove the log and prevent it from generating while runtime of my code executions.
Thanks
By default Asterisk-Java uses java.util logging so you can have a look at the JDK documentation on how to configure it.
This link might help you.
How do I disable the debug or "INFO" output from asterisk-java?
Can't you simply change the log level by name/package?
Logger.getLogger(org.asteriskjava.manager.internal.ManagerConnectionImpl.class).setLevel(Level.OFF);
You did not tell if you are using log4j or jdk logging
Googling on how to disable logs in asterisk-java gave this
http://www.asterisk-java.org/development/faq.html
Are you using something like log4j???
im not sure what your requirement is.
but if you dont want to see any logs at runtime then write all you logs at INFO or DEBUG level
then change the logLevel to ERROR or FATAL in log4jProperties.
but just understand that the purpose of logs is to see them during run time.
If you simply want to suppress output from the application, you could do
System.setOut(new PrintStream("stdout.log"));
System.setErr(new PrintStream("stderr.log"));
(Or create your own PrintStream subclass which just suppresses all output.)
This has been solved with help of mr srikanth yaradla.
I was needed to do the changes in the logging.properties file.which was not done by me earlier.

google app engine service unavailable

I'm was following http://googcloudlabs.appspot.com/ tutorial to create new Google App Engine project. It throws me an error as per below when I try to run the from my local host, but when I deployed it working fine. (http://mynewcloudcom.appspot.com/). Please help.
HTTP ERROR: 503
Problem accessing /. Reason:
SERVICE_UNAVAILABLE
Powered by Jetty://
Eclipse Console
Mar 05, 2012 10:42:46 AM com.google.apphosting.utils.jetty.JettyLogger info
INFO: Logging to JettyLogger(null) via com.google.apphosting.utils.jetty.JettyLogger
Mar 05, 2012 10:42:46 AM com.google.apphosting.utils.config.AppEngineWebXmlReader readAppEngineWebXml
INFO: Successfully processed C:\Smartag_Eclipse_Project\DontEditProject\war\WEB-INF/appengine-web.xml
Mar 05, 2012 10:42:46 AM com.google.apphosting.utils.config.AbstractConfigXmlReader readConfigXml
INFO: Successfully processed C:\Smartag_Eclipse_Project\DontEditProject\war\WEB-INF/web.xml
Mar 05, 2012 6:42:48 PM com.google.appengine.tools.development.DevAppServerImpl start
INFO: The server is running at http://localhost:8888/
Mar 05, 2012 6:42:48 PM com.google.appengine.tools.development.DevAppServerImpl start
INFO: The admin console is running at http://localhost:8888/_ah/admin
Found the answer. I need to run in JDK1.6. Once i changed the Java Compiler(right click project -> properties -> Java Compiler -> (Check) Enable project specific settings -> change the Compiler compliance level), its works fine now. Thanks.
I had the same problem. I justed changed the port from 8888 to 80 in the Debug Configuration and it worked for me.
I had the same issue.
for me the problem was one of my filters had an exception. specifically objectify - it was not loaded properly. you can delete the filter and see if that's it
When using Java 1.7, also check for the Execution Environment and set it to JavaSE-1.7.
You can look into the Execution Environment in:
Right Click -> Properties -> Java Compiler
And you have the option above Restore Defaults and Apply.
I faced the same issue and resolved it by selecting "Automatically select an unused port" in run configuration.
Sometimes it happens there is a "hanging" process that blocks the port. Therefore changing port in Run configuration helps, as well as checking "Automatically select an unused port" in run configuration.
It happened with me too. In my case, I had Run the project and due to some error in my code, the Project ran with errors. So, I debugged it and Run it again but without cancelling the earlier one in the console and it gave me that error. After cancelling or stopping the Project, it ran fine.
i had the same issue. Seems that Plugin is stocked on creating and opening the socket for the server. i don't really know why happens, I've resolved in this way.
Open Run Configurations.
Open Server tab. Change the Embedded server Port.
Open Arguments tab.
3.1 - VM arguments box. i've deleted all that stuff there and just let this
line and save changes and run it.
-Xmx512m -javaagent:/Applications/eclipse/plugins/com.google.appengine.eclipse.sdkbundle_1.7.5/appengine-java-sdk-1.7.5/lib/agent/appengine-agent.jar
It has worked pretty good 4me.
If someone know which events or configuration change are the reason for . please let us know it
NOTE: "I'm not responsible for unexpected behave. I'm don't know if there is side effects ahead"
The solution working for me is to run appEngineServer from command line using Gradle, as comments in generated build.xml for endpoints module proposes. And gradle config includes option for Java 1.7 compatibility, so it's no reason to use Java 1.6 if You want 1.7:
gradlew modulename:appengineRun
Currently, the appengine gradle plugin's appengine devappserver
launch doesn't interact well with Intellij/AndroidStudio's
Gradle integration. As a temporary solution, please launch from the command
line. ./gradlew modulename:appengineRun
I had a condition where a servlet defined in the web.xml with non existent class name. I specified proper class name, worked!

Extracting startup errors from Spring contexts

Consider the following output from a Tomcat server under Eclipse:
INFO: Initializing Coyote HTTP/1.1 on http-8080
INFO: Initialization processed in 634 ms
INFO: Starting service Catalina
INFO: Starting Servlet Engine: Apache Tomcat/6.0.20
SEVERE: Error listenerStart
SEVERE: Context [/MyServlet] startup failed due to previous errors
I would like to figure out what exception caused "Error listenerStart", but Spring seems to be preventing me from finding the error via Eclipse. I'd love to start Catalina manually, but that doesn't seem to do anything.
What's the best way to find the hidden exception? I'm not afraid to use torture methods.
In my case, the answer was:
Debug java.util.logging.SimpleLogger to find out what exceptions were being hidden.
Figure out that my logging.properties file, cut-and-pasted from the Tomcat docs, was bunk. Several exceptions were going into black holes in log files (maybe they weren't flushed)? Switching everything to a single ConsoleLogger enabled me to see all exceptions.
Make sure that -Djava.util.logging.config.file="/<path>/logging.properties" was present in my Run Configuration.
Try to configure logger (Log4j for example) and log errors to console.
Check tomcat's logs directory, see if it logged to an alternate log file.

Categories