How can I tell tomcat (within eclipse) to make the log file a rolling log file? - eclipse

There was a great question/answer on setting up tomcat (within eclipse) to write log files to disk (see answer by #codesta):
Where can I view Tomcat log files in Eclipse?
Through the Edit Launch Configuration Properties wizard in eclipse I can specify which file to write my logs to. However, since it is a single file, it gets overwritten every time the server restarts. I already have access to the current log through the console in eclipse, but is there a way to make this a rolling file so that I can have history?
I have played around with only specifying a directory in the file path, but then no logs are written out.

Follow the instructions to use log4j for Tomcat's internal logging:
http://tomcat.apache.org/tomcat-6.0-doc/logging.html#Using_Log4j
The tomcat-juli jars that you need can be found here:
http://apache.osuosl.org/tomcat/tomcat-6/v6.0.35/bin/extras/
Substitute whatever version of Tomcat you're using. Your CATALINA_HOME for the purpose of libraries will be wherever you have Tomcat installed, but the CATALINA_HOME for your configuration files will likely be:
workspace.metadata.plugins\org.eclipse.wst.server.core\tmp0

Related

Tomcat and Eclipse vs Intellij

I am working with Intellij but some of my co-workers don't. When I was writing install doc, I realized that Tomcat is not managed the same way on the two IDEs.
Which is a problem considering what happened next when I tried to set up our project on Eclipse.
Basically, on Intellij, you select a Tomcat on your computer and it will literally copy the war into the webapps folder and run the server with everything working fine.
I am not a user of Eclipse so I might have misunderstood something, but I found that when you create a Tomcat server, it will embed the one you gave it to it. Doing that is a bit of an issue when you are working with logback, because usually you set your logs location directly into the Tomcat folder. And in Eclipse you are working out of this folder.
So, I can't run my application because it can't find the location of the logs folder at the fine place.
Is there a way to use Tomcat in Eclipse like Intellij? Or did I just miss something because I am kind of new with Eclipse?
See the FAQ: (1) (2)
I found that when you create a Tomcat server, it will embed the one you gave it to it.
You have to be more specific with your description. How you do things and what do you see. What do you mean by "embed"? What is the actual failure that you are observing with your logging?
There are different ways to do things.
For me by default Eclipse does not embed Tomcat, but runs it as a proper java process. (org.apache.catalina.startup.Bootstrap) You should be able to see it with jconsole and similar tools.
It runs your web application expanded, i.e. without zipping it into a war file. It creates a separate configuration of Tomcat, i.e. runs it with separate CATALINA_HOME and CATALINA_BASE directories (as documented in RUNNING.txt file of Apache Tomcat). The CATALINA_HOME directory stays untouched and CATALINA_BASE directory is ${workspace}/.metadata/.plugins/org.eclipse.wst.server.core/tmp0 etc. A logs directory can be found there.
One known caveat is that java.util.logging is not configured by default (the system properties java.util.logging.manager and others are not set). See "How do I enable the JULI logging" item in the FAQ. -- In the same way you will set any other system properties that you may need.
The default configuration of java.util.logging (as provided by JRE) is to log everything to the console, without creating any files.

weblogic 12c not loading application properties file

We're moving from OC4J to WebLogic and have some properties files that reside outside of the EAR file. In OC4J we simply put them in the "applib" directory. Everything I've read so far about WebLogic says to put the file in the user_projects\domains\mydomain directory, but that's not working.
Is there another directory that I need to use or how do I force WebLogic to look in user_projects\domains\mydomain for the application properties files?
Maybe not the best solution, but at least a workaround. I edited wls12130\oracle_common\common\bin\commEnv.cmd and appended the domain home dir to this line:
set WEBLOGIC_CLASSPATH=%JAVA_HOME%\lib\tools.jar;%PROFILE_CLASSPATH%;%ANT_CONTRIB%\lib\ant-contrib.jar;%CAM_NODEMANAGER_JAR_PATH%;%DOMAIN_HOME%

Deploy a War file with Eclipse and Tomcat 6 without a build file

I know there are a bunch of posts on this topic, but I can't seem to figure it out. Here is my setup:
- Eclipse Indigo
- Tomcat 6
- Struts WAR file that I imported into Eclipse from http://www.manning.com/dbrown/SampleApplication.zip
I added the server to Eclipse, and added the project to the server. It runs fine, but I'd like to make some changes to the XML and java files (not the jsp files). I was under the impression that Eclipse takes care of the deployment after I save and restart the server, but I guess this isn't the case. I looked into creating an ant file to do a custom build, but I'm not really sure how to make it since I don't even know how to do a deployment "manually". How would I go about doing a manual deployment? Thanks.
A war file is usually created by exporting it from an IDE like eclipse, netbeans, etc.
While generating a war file there is 2 options,
You can include your java files with it
You can avoid java files from it.
In both the cases class files will be there which are created from java files. Class files will be able to take care of the actions of java class.
If the war file which you down loaded is not having those java files, you will not be able to use it with eclipse, where as it will work fine if you are putting it into tomcat directory for running.
For running a war file manually just put it into tomcat webapps folder and run tomcat.
Then you can access the pages using the url.
http://localhost:8080/yourprojectname/
If you want to check whether the war file contains any java files, after starting the tomcat server it will extract the war file into the same directry, where you can search for java files.
If you want to run the project from eclipse,
import it into eclipse, open index.jsp page
right click-> run as-> run on server
if you have not yet configured the server yet,select the server in the list, specify its installation path, then add projects into server in next step, finish it. then it will load your project.
Please provide little more details so that we can help you better.
manual: copy the war in the tomcat folder then start tomcat.
if you want to use eclipse you need to click redeploy war first by right clickling the deployed war in the servers tab under tomcat.

Adding server-specific options to an Eclipse-managed Tomcat instance (in server.xml)

How can I make sure that the server.xml which Eclipse produces for every separate project that relies on Tomcat, will always contain a specific option, which I added manually?
I'd like to add a bunch of <Context> mappings to the server.xml file. I tried doing that in the server.xml in the main tomcat dir - didn't work.
Then I saw that Eclipse builds a temporary folder for every project that uses Tomcat. This folder also containes this server.xml file. I edited it, and voila, it worked. However, soon after that the same file got updated by Eclipse, with the original data that it contained.
It is not very efficient to manually copy and paste the code every time before I run/restart tomcat. I hope there is a more permanent way.
Let's assume you have configured tomcat 5.5
If you have configured your tomcat server in eclipse using all default options, you want to edit the server.xml located at WORKSPACE_LOC\Servers\Tomcat v5.5 Server at localhost-config\server.xml

Controlling catalina_home in liferay eclipse tomcat

I have a development system ( linux-Liferay6-tomcat6-Eclipse Helios) that I have version-controlled in SVN. When I roll it out for a new developer in what amounts to a fresh installation, the paths for the tomcat server are wrong because they were written in various places as absolute paths reflecting my desktop.
It looks to me that I could modify catalina.sh or startup.sh to fix this problem, or part of it maybe, but I'd rather have a fix that leaves Tomcat unmolested. I could also require developers to set CATALINA_HOME, but that would break any other tomcat installations they might have ( my own situation in fact).
For instance, maybe a custom Ant script that figures out the path and sets CATALINA_HOME just for the shell thats running this particular Tomcat? Is there a way to do this in the Eclipse IDE, I looked but don't quite see it?
Ideas?
John Fisher
If you're using ant and the liferay plugins sdk, you're supposed to create a build.${username}.properties file in the root folder of the plugins sdk. (substitute ${username} with the name you log in to your OS). In this you override the location of your appserver, e.g. tomcat. Take a look at build.properties. Though you're not supposed to change this file, you can copy the one interesting line (note: it's preconfigured for tomcat) and use it for the appropriate settings.
This way you'll have a per-user setting for the required value.
The server (if you require to start it in eclipse) is to be created in each eclipse instance, independent of each other. The Liferay IDE plugins for eclipse can help you with setting this up.
As I expect the server to be modified by everybody on a frequent basis, I never share the server "project" in version control, but keep it strictly local. It's easily recreated if lost.