Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

collect access.log to docker log driver #84

Closed
1026524749 opened this issue Sep 21, 2017 · 6 comments
Closed

collect access.log to docker log driver #84

1026524749 opened this issue Sep 21, 2017 · 6 comments

Comments

@1026524749
Copy link

Tomcat catalina.log is collected to stdout,but access.log is output to file in the container。
How do I to collect access.log by docker log driver?

@tianon
Copy link
Member

tianon commented Sep 22, 2017

I think the following section in the default conf/server.xml is probably relevant:

        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />

If all else fails, you could create a short Dockerfile that's FROM tomcat:X.Y which creates a symlink from the access log file to /dev/stdout (like NGINX does: https://github.com/nginxinc/docker-nginx/blob/48a4c531fc4bfa80d4270f20a67e2e958856860c/stable/stretch/Dockerfile#L91-L93).

@srossross
Copy link

I've modified my conf/server.xml, this works for me:

        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="/proc/self/fd"
               prefix="1" suffix="" rotatable="false"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />

@tianon
Copy link
Member

tianon commented Oct 12, 2017

Nice, thanks for confirming @srossross! 👍

@connachtguy
Copy link

I've modified my conf/server.xml, this works for me:

        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="/proc/self/fd"
               prefix="1" suffix="" rotatable="false"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />

I have a containerized app that spews it's log messages to standard out. It runs on tomcat, and we created a symbolic link from the tomcat access log to /dev/stdout which seemed to work, but we found that occasionally the application messages were clashing with the access log messages. I'm wondering if there's any reason to think this /proc/self/fd approach would be any better?

@arulrajnet
Copy link

arulrajnet commented Feb 13, 2022

In server.xml

<Valve className="org.apache.catalina.valves.AccessLogValve" 
            directory="/dev" prefix="stdout" suffix="" pattern="%h %l %u %t &quot;%r&quot; %s %b" 
            buffered="false" fileDateFormat=""/>

This sends the accesslog into stdout.

@sujiansoft

This comment was marked as spam.

@docker-library docker-library locked as resolved and limited conversation to collaborators Feb 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants