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

Add option, to log to file #1933

Closed
4 tasks done
lonix1 opened this issue Jul 5, 2023 · 8 comments · Fixed by #2115
Closed
4 tasks done

Add option, to log to file #1933

lonix1 opened this issue Jul 5, 2023 · 8 comments · Fixed by #2115
Labels
feature add new functionality

Comments

@lonix1
Copy link
Contributor

lonix1 commented Jul 5, 2023

Clear and concise description of the problem

BACKGROUND

Woodpecker seems to log to stdout only, and thus to docker's built-in "json driver". The logs can be access like so:

  • $ docker logs -t $CONTAINER_NAME
  • tail -f /var/lib/docker/containers/$CONTAINER_ID/$CONTAINER_ID-json.log

PROBLEM

When the container is recycled, the logs are lost. The workaround is to use another logging tool, but that is unnecessary complexity, especially for small deployments.

Also, in general, the logs are not in a friendly format - it's much simpler, especially in small deployments, to simply have the log in a file that can be easily manipulated. Not everyone uses large complex logging apps and servers, etc.

Suggested solution

SOLUTION

Many apps have an option to log to file as well. Gitea does that, for example.

It would be nice if the log could be sent to a file instead of (or in addition to) stdout. If enabled, it could be written to /var/lib/woodpecker/app.log by default.

Personally, I would mount it as /var/log/woodpecker.log:/var/lib/woodpecker/app.log so that I could have it on the host, and use logrotate on it.

Alternative

An unnecessarily complicated environment that includes log aggregation and monitoring, and who knows what else. For small servers that is overkill and hard to manage.

Additional context

Thank you for considering it!

Validations

  • Checked that the feature isn't part of the next version already [https://woodpecker-ci.org/faq#which-version-of-woodpecker-should-i-use]
  • Read the Contributing Guidelines.
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
@lonix1 lonix1 added the feature add new functionality label Jul 5, 2023
@6543 6543 changed the title Log to file Add option, to log to file Jul 9, 2023
@anbraten
Copy link
Member

I don't see the underlying issue.

Currently a no as of following reasons:

  • you can already use bash pipes to write to a file and add mounts
  • this seems to be a pretty special docker backend related use-case and would introduce other issues exp when using multiple agents etc

@lonix1
Copy link
Contributor Author

lonix1 commented Jul 10, 2023

you can already use bash pipes to write to a file and add mounts

I don't understand what you mean?

a pretty special docker backend related use-case

As mentioned above this is common for dockerised apps, to write to stdout and/or file

Nonetheless, thanks for considering it.

@lonix1
Copy link
Contributor Author

lonix1 commented Jul 15, 2023

you can already use bash pipes to write to a file and add mounts

I don't follow?

@lonix1
Copy link
Contributor Author

lonix1 commented Jul 18, 2023

Hi @anbraten You closed this issue but I don't understand your reply? Do you mind elaborating, or reopening?

@6543 6543 reopened this Jul 18, 2023
@6543
Copy link
Member

6543 commented Jul 18, 2023

so if we would add some WOODPECKER_LOG_FILE witch is by default `` so it's stdout

and if set, instead of stdout it will print to mentioned destination?

@lonix1
Copy link
Contributor Author

lonix1 commented Jul 18, 2023

That would be awesome.

Some apps log only to stdout, some only to file and some to both. I think "either or" is good enough. Your WOODPECKER_LOG_FILE idea is simple and good.

Something interesting that traefik (or gitea, I can't remember) does: if you log to file instead of stdout, it logs a few lines to stdout anyway, like this:

datetime : app started
datetime : logging at INFO level
datetime : logging to '/var/lib/appname/app.log'...

So if someone checks the docker logs, he won't be confused why they're empty.

@lonix1
Copy link
Contributor Author

lonix1 commented Jul 18, 2023

Aaaah, I just realised that it's not as simple as initially thought - there's another item to consider.

If the app receives a USR1 signal, it must release the log file, so the host can logrotate it (assuming we mount the log file to the host, which is the entire point). I'm unsure how that's done, but I know that gitea does that.

So maybe this is a long-term backlog item.

@6543
Copy link
Member

6543 commented Aug 4, 2023

-> #2115

@6543 6543 closed this as completed in #2115 Aug 7, 2023
6543 added a commit that referenced this issue Aug 7, 2023
close  #1933

---------
*Sponsored by Kithara Software GmbH*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature add new functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants