Where is Tomcat Console Output on Windows - windows

I used to start tomcat from its bin folder with the startup.bat. By running that script it opened a java window in which I can see the outputs from tomcat. However, I've been told that this is not the right way to start tomcat on a windows server. Therefore I start tomcat now over the service program. By doing so no java window is being opened anymore and therefore I can't see the output msg from tomcat.
I have also looked into the logs folder of tomcat. Those saved outputs are not the same as the one I had/have in java window. Does anyone know where I can find those outputs?
Many thanks in advance for any advices.

If we assume your install is in C:\program files\apache software foundation\apache-tomcat{ver}\
then it is inside, in the log directory, in a file catalina.out.
C:\program files\apache software
foundation\apache-tomcat{ver}\logs\catalina.out
It's worth to note the name of the file depends on your configuration, also the name of the logs directory can be different depending on configuration but I assume you preserved default config.

In Windows (I am using Windows 10) you should do these to check the running application's logs:-
Install Notepad++
Open C:\Program Files\Apache Software Foundation\Tomcat {ver}\logs\tomcat{ver}-stdout.{date}.log in Notepad++
Open View menu and enable 'Monitoring' in Notepad++

Usually the logs should be in $TOMCAT_HOME/logs
When running tomcat as a service, i have noticed that Tomcat sometimes generated logs in the folder where tomcat was started from so also check $TOMCAT_HOME/bin for any possible log files.
This is why you should configure Log4j so that you have control of where the log files are created.

There is no such thing. There is no catalina.out on MS Windows. On MS there is catalina-datetime-in-some-random-format.log but that is NOT catalina.out nor does it contain same information.
On a real operating systems there is catalina.out that contains all output from JVM both stdout and stderr. On MS windoh! ;) it is just a log file for Tomcat JUL log file (not CONSOLE/stdout/stderr). Then there are catalina-stdout.log and catalina-stderr.log files.
So every single time you need to find some information on M$ you have dig through all three files. Most of contain duplicate information making it absolute hell to try to process the logs via any automation like ELK stack.

Related

Why isn't SpringBoot (WAR FILE) writing to its log file on Linux but writes to log on Windows & Mac?

I have a simple SpringBoot WAR file in Tomcat that uses the default SpringBoot logging mechanism to write to the log specified in application.properties.
This mechanism works great in both Mac and Windows. The log works fine.
Yet, for some reason, in Ubuntu 20.04 and 20.11 although Spring creates the log file, it never writes to it. It's always zero bytes.
The log file on Ubuntu (/var/lib/tomcat9/logs) has these permissions:
-rw-r----- 1 tomcat adm 0 Jan 31 07:53 ws.log
The same SLF4j log entries that appear in Linux also appear in both Windows and in Mac.
This Linux log problem has baffled me now for over a week and I cannot find any solutions. If I have failed to include needed details, I will gladly include any requested.
Would most appreciate some ideas of what to try next.
Thanks

Running Tomcat from windows 10 bash shell

I installed tomcat server on windows10 bash shell. Though it says apache is running.. its not opening admin panel in browser. Browser says 'Connection can't be reached'
Have someone tried this ever before? Please share your inputs.
Thank you
I am assuming you are referring to Bash for Windows (Ubuntu) on Windows 10. Yes Tomcat server can be installed and run from Bash for Windows with no need to install Tomcat in the Windows environment.
First, you may want to check if any local server is running on Windows 10 port 8080 - the default port for Tomcat, or whatever port you are configuring Tomcat for.
Second, open BASH for Windows and install Java. I used Oracle Java JDK 8 (http://www.oracle.com/technetwork/java/javase/downloads/index.html) and downloaded the tar.gz file.
Extract the tar.gz and copy to a standard directory like /usr/local/java or in the /opt/ directory for easy access.
Create JAVA_HOME and JRE_HOME environment variables that link to your java location.
I also updated the alternatives to map java, javac, and javaws. You can use this link to assist (http://askubuntu.com/questions/56104/how-can-i-install-sun-oracles-proprietary-java-jdk-6-7-8-or-jre)
Then download the tar.gz of Tomcat. Again, I used Tomcat 8.5 for my scenario and extract the files to your chosen directory.
Last, run the startup script located in the bin folder of the tomcat extracted folder. You should have a working Tomcat version.
Use the curl command to validate - curl localhost:8080
If you want to change the admin privileges, edit the tomcat-users.xml file located in the conf folder within the extracted tomcat directory.
Access to the tomcat server can also be done through the Windows system and not just through the Bash for Windows CLI.
Hope this helps!

How to start tomcat server manually

I installed tomcat 7 in my windows 7.Then ran C:\apache-tomcat-7.0.57\binstartup.bat,one window will open for 1 second and closes.when i hit http //localhost/8080 ,its not dsiplaying anything.I just checked C:\apache-tomcat-7.0.57\conf/server.xml and port is 8080.
Can somebody help on this.
Read RUNNING.txt and create C:\apache-tomcat-7.0.57\bin\setenv.bat file that sets JRE_HOME (or JAVA_HOME) path for Tomcat.
Sample from Tomcat 7 RUNNING.txt file using Java 6 JRE:
set "JRE_HOME=%ProgramFiles%\Java\jre6"
exit /b 0
You need to set Java_Home in Cataline.bat first in order to run TomCat server.
Additional Information for running project using Tomcat Server.
You can cd into the folder where tomcatXX/bin is through command line and run "run startup". So, when you , run startup on command line it tries to run script from startup.bat file, probably it crashed because port to be used by TomCat to run server is already in use. If you try to point your url to localhost:8080, if TomCat's home page appears, that would be because your server is already running. You should ideally also try to point to Windows -> Preference -> Runtime Environment. Check if Tomcat server is added in list under Server Runtime Environment window, if not try to add that server by clicking Add button, and trying to locate where Tomcat/bin is stored. If that still doesn't help, I would suggest you to also try right clicking a project on your IDE then click Run As, then click Run Configuration, it will give you option to run application using TomcatServer. List of servers will be found on left side of Run Configuration window.

How to run Solr 4 in Tomcat locally?

I've been trying to set up Solr 4.3 on my home PC (in Tomcat 7) but it doesn't run. I have set up Tomcat and deployed the solr.war file which both unpacks and shows up in the Tomcat Web Apps Manager screen in Tomcat but its not running and clicking the start button doesn't do anything (as it should already be running in the first place).
Here is my solr.xml context file in Tomcat which also gives the path to the solr.war file and where my solr Cores are (which is the default Collection1):
<Context path="/solr" docBase="C:/LocalApps/Tomcat/apache-tomcat-7.0.40/webapps/solr.war" debug="0" crossContext="true">
<Environment name="solr/home" type="java.lang.String" value="C:/LocalApps/Solr/solr-4.3.0/example/solr/" override="true"/>
</Context>
this is the error log in tomcat:
INFO: Starting Servlet Engine: Apache Tomcat/7.0.40
Jun 09, 2013 11:04:07 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor C:\LocalApps\Tomcat\apache-tomcat-7.0.40\conf\Catalina\localhost\solr.xml
Jun 09, 2013 11:04:07 PM org.apache.catalina.startup.HostConfig deployDescriptor
WARNING: A docBase C:\LocalApps\Tomcat\apache-tomcat-7.0.40\webapps\solr.war inside the host appBase has been specified, and will be ignored
Jun 09, 2013 11:04:07 PM org.apache.catalina.startup.SetContextPropertiesRule begin
WARNING: [SetContextPropertiesRule]{Context} Setting property 'debug' to '0' did not find a matching property.
Jun 09, 2013 11:04:09 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error filterStart
Jun 09, 2013 11:04:09 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/solr] startup failed due to previous errors
You need to install the jars for logging as explained here.
Just copy all the mentioned files into your tomcat/lib dir. And restart Tomcat.
Copy the jars from solr/example/lib/ext into your container's main lib directory. These jars will set up SLF4J and log4j.
Exactly where this lib directory is highly variable. For a Debian or
Ubuntu server using the Tomcat package available from the OS vendor,
this is likely to be /usr/share/tomcat6/lib or
/usr/share/tomcat7/lib.
Copy the logging config from solr/example/resources/log4j.properties into a location on the
classpath. Usually you can use the same location as the jar files
above. Edit the configuration file for your preferred log destination.
Optionally, if you did not place log4j.properties on the classpath, set java option
-Dlog4j.configuration=file:///path/to/log4j.properties
Download latest solr-4.x.zip file.
Extract zip file somewhere like C:\solr setup.
Apache Tomcat (version greater than 5) and Java 6 or greater should be installed. Copy solr-4.x.war file from “C:\solr setup\solr-4.3.0\dist” to “Apache Tomcat” webapps folder most probably in C:\Program Files\Apache...\Tomcat...\webapps\ and rename copied war file to some meaningful name like solrTest.Start Tomcat. If already running then restart Tomcat. New folder with same name as of war file (solrTest) will be created.
Stop Tomcat. Copy bin and collection1 folders from C:\solr setup\solr-4.x\example\solr to C:\Program Files\Apache ...\Tomcat...\webapps\solrTest.
Copy all jars from C:\solr setup\solr-4.x\example\lib\ext to C:\Program Files\Apache...\Tomcat...\lib. SOLR 4.x will use these jars for logging.
Create xml file in C:\Program Files\Apache...\Tomcat...\conf\Catalina\localhost\ with same name as of war file (solrTest.xml) with contents as given below. Tomcat looks for this xml file to get a start of the application.
Update C:\Program Files\Apache...\Tomcat...\webapps\solrTest\collection1\conf\schema.xml and add required fields and update too.
Remove copy fields if not required. Usage of copy fields is available in same file.
Update C:\Program Files\Apache...\Tomcat...\webapps\solrTest\collection1\conf\solrconfig.xml.
Update physical index path in tag like ${solr.data.dir:C:/Indexes/solrTest Index/}. If it will be commented then C:\Program Files\Apache...\Tomcat...\webapps\solrTest\collection1\data\ directory will be used by default. DataDir tag is available in file. No need to add your own.
Update replication entries to set either master or slave in replication request handler.
Try accessing “...localhost:portNumber/solrTest”. If no error comes then you have successfully configured SOLR 4.x.
The easiest way to get started with Solr on Tomcat is to use HDS (Heliosearch Distribution for Solr), a
Tomcat/Solr distribution
It's a super-set of Apache Solr, containing an additional "server" directory that is a pre-configured (threads, logging, connection settings, message sizes, etc) Tomcat based Solr server.
Some other implementation notes:
start scripts can be run from anywhere, and allow passing JVM args
on command line (just like jetty, so it makes it easier to use)
start scripts work around known JVM bugs
start scripts allow setting port from command line, and default stop
port based off of http port to make it easy to run multiple servers on
a single box)
zkcli, the start script for the solr zookeeper tool, will auto-explode the WAR if necessary
the "server" directory has been kept clean but stuffing all of
tomcat under the "server/tc" directory
To start:
$ cd server
$ bin/startup.sh
To start on a different port (e.g. 7574):
$ cd server
$ bin/startup.sh -Dhttp.port=7574
To shut down:
$ cd server
$ bin/shutdown.sh -Dhttp.port=7574
The scripts even accept -Djetty.port=7574 to make it easier to
cut-n-paste from start examples using jetty. The "example" directory
is still there too, so you can still run the jetty based server if you
want.
Check the localhost_yyyy_mm_dd.log logs created by Tomcat. It should typically show you the reason for this issue. Full stack trace might not be displayed in console...
I had some problem doing the same thing, the official documentation is not really helpful about this. I wrote a blog post about it which reads:
Solr install
Download and unpack the latest version of Solr, somewhere on the disk.
cd /tmp
wget "http://mirrors.ircam.fr/pub/apache/lucene/solr/4.6.0/solr-4.6.0.tgz"
cd /opt
sudo tar zxvf /tmp/solr-4.6.0.tgz
sudo chown -R tomcat:tomcat solr-4.6.0
Here, I use /opt, but you can install it anywhere as long as Tomcat has access to it. Just to be sure, make Tomcat the owner, so it can read and write in Solr folders.
Deployment
Now, let's deploy the Solr webapp on Tomcat. To do so, we will take advantage of an XML context configuration file, wich we will use to deploy and configure Solr.
In your Tomcat installation folder, create a new XML context configuration file in conf/Catalina/localhost. The base name of the file will define the Solr context path.
We first need to define ${solr.home}. Here, we use the example Solr configuration provided in the distribution. It is located in /opt/solr-4.6.1/example/solr.
To avoid startup errors, we need to add some jars to the webapp classpath, located in /opt/solr-4.6.1/example/lib/ext. But we don't want to pollute Tomcat's lib folder with Solr jars, so we just declare a virtual loader.
We also need to configure Log4J properly. Here we use the Log4J configuration file provided in Solr distribution in /opt/solr-4.6.1/example/resources, by adding the folder in Solr classpath.
<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="/opt/solr-4.6.1/dist/solr-4.6.1.war">
<Environment
name="solr/home"
type="java.lang.String"
value="/opt/solr-4.6.1/example/solr"
override="true" />
<Loader
className="org.apache.catalina.loader.VirtualWebappLoader"
virtualClasspath="/opt/solr-4.6.1/example/lib/ext/*.jar;/opt/solr-4.6.1/example/resources/" />
</Context>
Save the file, wait for Tomcat to read it and deploy the war.
That's it! Solr is up and running.
Here is instruction provided by Tony at Drupal for Windows with XAMPP installed:
Preliminaries
Make yourself a nice cup of tea
Make sure you have the Windows Java environment installed. It's up to version 6 at the moment.
I assume you use XAMPP to run Apache and MySQL and latest version of PHP5
Installing Tomcat
If you installed XAMPP with Tomcat, go to your Service Tray, stop XAMPP services and remove the Tomcal directory from within your XAMPP installation. Then restart your XAMPP again. The reason is that you want to be able to configure Tomcat easily from Services Tray in Windows. If Tomcat runs under XAMPP, it does not show up in the Services Tray.
Before you install Tomcat, copy the file c:\windows\microsoft.net\framework\v1.1.4322\msvcr71.dll to c:\windows\system32\msvcr71.dll If you don't do this, Tomcat won't start up.
Now install Tomcat 6.x. Start it running. You should get a page showing at http://localhost:8080 if Tomcat is working.
Have a peek at the file structure of Tomcat. It is very straightforward. Note the directory called webapps.
Now have a nice cup of tea.
If you're on Linux, check: Apache Solr 4.6.0 installation.

create .bat file to clear apache logs

I want to create a batch file to clear my Apache error log files, because they keep getting large very quickly. I tried using the following script:
#echo off
type NUL > C:\Program Files\Apache Software Foundation\Apache2.2\logs\access.log
type NUL > C:\Program Files\Apache Software Foundation\Apache2.2\logs\error.log
Unfortunately, this script doesn't work. I am using Windows 7. Any suggestions?
Won't work - Apache keeps the log files open at all times. You'd have to stop Apache, THEN truncate, and restart Apache. Another option would be to use a log rotater to do this for you automatically.

Resources