Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Can tomcat write to apache access_log/error_log

Posted on 2014-02-03
5
Medium Priority
?
467 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 1200 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 300 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month12 days, 21 hours left to enroll

972 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