Solved

Can tomcat write to apache access_log/error_log

Posted on 2014-02-03
5
415 Views
Last Modified: 2014-02-10
Can tomcat write to apache access_log/error_log?
0
Comment
Question by:jmarkfoley
  • 3
5 Comments
 
LVL 8

Assisted Solution

by:Surrano
Surrano earned 400 total points
ID: 39831780
I can interpret this question in several ways;

Q: Is it normal for tomcat (as opposed to its apps) to write to apache logs?
A: No, tomcat has its separate log dir and naming conventions

Q: Is it possible to configure tomcat so that it uses the same log files?
A: Yes but it leads to confusion since both Apache and Tomcat will keep those files continuously open, as opposed to periodically appending messages, i.e. one will overwrite the other and all the messages will be garbled

Q: Is it possible to configure *both* to use the *same* output without corrupting each other?
A: Yes if you use the pipe version to redirect output to a command that can safely cat at the end of a file and flush after every message but that may be a major performance impact. Another possibility is to write into a FIFO which is in turn read and archived by a single process. It will be buffered but safe.

Q: Is it possible that a tomcat application "accidentally" (*ahem*) writes into Apache logs?
A: Yes, if the webapp runs with sufficient permissions to modify the apache log files then it will be able to do that. But I'd consider calling such a webapp a malware.
0
 
LVL 6

Assisted Solution

by:Mahesh Bhutkar
Mahesh Bhutkar earned 100 total points
ID: 39832053
Tomcat has five types of logging that we can configure, such as Application, Server, Console, Access, Host manager.
0
 
LVL 1

Author Comment

by:jmarkfoley
ID: 39832853
tomcat seems to be logging to the Apache access_log; the messages are in a tomcat-like format, e.g:

198.234.157.10 - - [04/Feb/2014:10:48:58 -0500] "GET /ohprs/images/slideShow/Blizzard1.jpg HTTP/1.1" 304 -

I'm suspecting tomcat for doing the logging as this does not appear to be the default Apache log format.

I've found that writing to stderr from jsp programs logs to $CATALINA_HOME/logs/catalina.out. That is probably adequate for my needs without going through all the complexity of using JULI or Log4j, but I'd rather log to Apache's access_log or error_log so I only have to examine one file.

Not doable?
0
 
LVL 1

Accepted Solution

by:
jmarkfoley earned 0 total points
ID: 39836012
Writing to $CATALINA_HOME/logs/catalina.out from System.err.println() does what I want. JULI or Log4j is vastly overcomplicated and time consuming for my needs.
0
 
LVL 1

Author Closing Comment

by:jmarkfoley
ID: 39846816
Writing to $CATALINA_HOME/logs/catalina.out from System.err.println() does what I want. JULI or Log4j is vastly overcomplicated and time consuming for my needs.
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Suggested Solutions

In my time as an SEO for the last 2 years and in the questions I have assisted with on here I have always seen the need to redirect from non-www urls to their www versions. For instance redirecting http://domain.com (http://domain.com) to http…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now