Instead of using maven goal "gcloud:run" I use "dev_appserver.py" to run my web app.
The app is an ordinary web app using Flexible Environment, Java 8, Jetty 9 in compatibility mode with Google App Engine. It uses a appengine-web.xml to specify a logging.properties file which is set to .level=FINE
How do I specify logging? Neither java.util.Logger or System.out.println seems to output anything in the console.
It all relies on Jetty and configuring to log. I made a solution with SLF4J. All needed is adding it as dependency.
Read more here http://aimmoth.blogspot.se/2016/06/logging-with-flexible-environment-and.html
Related
I have a microservice developed using Spring Boot. The application is deployed in pivotal cloud foundry. I have set the logs levels in logback.xml which is part of the application. In order to change the log level , I have to update the logback.xml and rebuild / redeploy the app. Is there a better way to do this without having to redeploy the app? Is there a way to set log level as env variable in PCF?
I have not used logback so don't know much on it. But may be this thread can help - Set Logging Level in Spring Boot via Environment Variable
If you are using Spring Boot 1.5 or higher, and PCF 1.9 or higher you can change log levels from the Apps Manager without having to redeploy:
http://docs.pivotal.io/pivotalcf/1-9/console/using-actuators.html#manage-log-levels
Have you ever thought of externalizing your application configuration.... Pcf provides a service called config-server, which uses a git repo for maintaining your application configuration....
Using spring boot actuator, you can actually reload the updated configuration without actually doing redeploy/rebuild of your app.
This links should help you:
https://docs.pivotal.io/spring-cloud-services/1-5/common/config-server/index.html
https://spring.io/guides/gs/centralized-configuration/
We are trying to run the GWT (2.1) Speedtracer, but have trouble with it, since Jetty doesn't accept our JDBC resources (they work fine in Tomcat) - probably because the JAR containing the drivers is not found by it.
Is there a way to make the GWT speedtracer run without the Jetty Server?
Or how do I make the web.xml/context.xml compatible with both Tomcat and Jetty?
I would prefer to run it in Jetty - as long as this won't cause problems with tomcat.
If you want to use Tomcat:
The GWT documentation mentions, that you can use Speed Tracer on the server-side with the SpringSource tc Server (which is a Tomcat server).
If you want to use Jetty:
Using DataSources with the embedded GWT Jetty server is possible, but not easy. It's explained in this Google Group post for GWT 1.6. I have tried this with GWT 2.1, and it basically remains the same procedure. Here's a quick outline:
enable JNDI for the embedded Jetty:
add jetty-naming-*.jar, jetty-plus-*.jar
modify the JettyLauncher,
add the VM arg -Djava.naming.factory.initial=org.mortbay.naming.InitialContextFactory (or use jndi.properties)
create a jetty-env.xml (similar to Tomcat's context.xml)
define a resource-ref in the web.xml
As part of all the development of some use cases, I've used a properties file approach to handle almost all the configuration parameters in the project.
Even when this approach is a security safe approach, I need to be able to change this parameters on the application, so I need an admin web module to be able to change at runtime all the configuration on the properties file.
I would like to know if there's any WAR that I can put on my website to enable dynamic web application modification.
I found that the Apache Commons Configuration enables me to do runtime modifications, but I haven't found a CRUD application for properties files.
Does anyone know one?
Agreed with Isaac's and ruffp's comments. Even if you did manage a way to update the contents of the property files at runtime, this wouldn't solve the issue that most of the properties are likely loaded once and not read again until the application is restarted. You're best off using Java EE environment entries, or a backing database.
Another option is to use JMX management beans. These beans could then be accessed through any JMX management tool, including jconsole - or your could use any available web front-end to access them as well, including any provided by an application server.
I have a quite ordinary web application which logs with slf4j, which is fine, and I have used several slf4j backends without any problems.
Under Tomcat I just told logback to point at a location in the filesystem and log there, but now I want to deploy several independent instances of this application each in its own domain in a single Glassfish 3.0.1 instance, and I have now found that I would like my slf4j logging to work well with Glassfish.
What would be a good way (dare I say "best") to have my logging taken care of by Glassfish. Should I just flatten my logs to System.out with logback and let Glassfish handle the console output, or is there a better, standard way to reach the loggers inside Glassfish?
EDIT: Investigation has shown that GlassFish 3.0.1 does not provide neither the SLF4J API or a binding in the classes visible to a JSP-page with default configuration.
By providing slf4j-api-X.jar and slf4j-jdk14-X.jar the slf4j-logging events are forwarded to java.util.logging which is captured properly by Glassfish (see http://docs.sun.com/app/docs/doc/820-7692/abluj?l=en&a=view for details).
Investigation has shown that GlassFish 3.0.1 does not provide neither the SLF4J API or a binding in the classes visible to a JSP-page with default configuration.
By providing slf4j-api-X.jar and slf4j-jdk14-X.jar the slf4j-logging events are forwarded to java.util.logging which is captured properly by Glassfish (see http://docs.sun.com/app/docs/doc/820-7692/abluj?l=en&a=view for details).
Note: Glassfish logging does not capture stack traces.
I am searching any way for embedding Weblogic server in Java , I know its possible because we have maven plugins for Weblogic which embeds Weblogic in maven, But googling for it did'nt gave me useful output, Does anybody know how can we embed wemlogic in java program ?
WebLogic doesn't provide an embedded API so, even if it's a pure Java Server and if you can thus call weblogic.Server from Java code, you will have to handle everything yourself (starting the container, waiting until it's started, deploying things, waiting until they are deployed, etc). In other words, this will require some work.
Maybe have a look at the sources of Cargo, although Cargo isn't really starting an embedded Weblogic (i.e. running weblogic.Server in the same JVM). This will give you an idea of what has to be done. Or, depending on your needs, use Cargo Java API.
But if you need a full Java EE server and if this is an option, I would use GlassFish v3 in embedded mode instead of WebLogic, it will be much simpler. Check the following links and see yourself:
Embedding Glassfish V3 in Unit Test - Two Jars, Three Lines Of Code And Five Seconds Start With Deployment
Embedding EJB 3.1 Container Into Your Unit Tests - Boot Time: 5 Seconds
Using the EJBContainer API with or without Maven (but with GlassFish v3)
TOTD #128: EJBContainer.createEJBContainer: Embedded EJB using GlassFish v3
Do you need WLS specifically, of any servlet container would do? If the latter is OK, then use Jetty.
WLS is not designed to be embeddable. But you can do it. After all, WLS is just a class named weblogic.Server. Setup classpath correctly, setup PATH and other environment variables (see setDomainEnv.sh and startWeblogic.sh), start that class from Java, and you have an "embedded" WLS.
There is probably a way, but I don't know it. My experience from writing maven plugins tells me that the most likely way that the plugin works is that it starts up a new command line process just like you would normally start up the server. So in a sense, not really embedded it.
The best way to see is to track down the source of the plugin and see how they did it.
WebLogic doesn't support embedded mode like Glassfish but you can have control over your Weblogic using "WebLogic Maven Plugin", this provide several maven goals for managing and working with Weblogic instance.
See this link for further information.