2

I'm trying to use logger to send events to the local syslog server within Tomcat.

In Apache you can do the following:

LogFormat "%h %A %l %u %t \"%r\" %>s %p %b" Events

CustomLog “|/usr/bin/logger -t httpd -p local6.info” Events

However, I am trying to use the AccessLogValve in Tomcat, anything within "pattern" is interpreted as a string.

<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log" suffix=".txt" rotatable="false" resolveHosts="false" pattern="%h %l %u %t &quot;%r&quot; %s %b" />

Is there anyway to send access logs to a syslog server without using log4j or logback? We need to deploy this configuration to Prod hosts. Logger for Apache has been deployed to prod. We would prefer to use logger as this would require no changes to our prod Applications.

user3730717
  • 21
  • 1
  • 3

2 Answers2

1

Short answer: yes.

There is a similar question and answer: Tomcat access logging through log4j?

As log4j have built-in support for syslog, so it can do what you want.

Community
  • 1
  • 1
Ben
  • 391
  • 6
  • 13
0

Short answer : no, you can't for the moment.

For the access log file, Tomcat doesn't use any logging framework, and can only log to a file. The only solution would be to extend the AccessLogValve to do it yourself.

However there is a pull request which, if accepted, should allow anyone to do it more easily. (EDIT: it is already in tomcat-trunk actually, so available to tomcat8 I believe)

Cédric Couralet
  • 4,913
  • 1
  • 21
  • 21