简体   繁体   English

git-daemon的日志保存在哪里? (使用Cygwin在Windows上使用Git)

[英]Where are logs of git-daemon saved? (Git on windows using Cygwin)

I am running git-daemon as a windows service. 我正在运行git-daemon作为Windows服务。 (using Create Process) (使用Create Process)
The command used in service is: 服务中使用的命令是:

git daemon --reuseaddr --base-path=/data/test_work/ --export-all \
    --verbose --enable=receive-pack

Where do I see the logs of git daemon ? 我在哪里可以看到git daemon的日志?

Note: there is no file at /var/logs . 注意: /var/logs没有文件。

If you still need and want to do it, I have found a way to do that: just create a bash script with execution permissions and tell the daemon to log its stuff into one or two files (if you want to log stderr separately): 如果您仍然需要并且想要这样做,我找到了一种方法:只需创建一个具有执行权限的bash脚本,并告诉守护进程将其内容记录到一个或两个文件中(如果您想单独记录stderr):

#!/bin/bash

# Git daemon launchd startup command.

GIT_RO_USER="git-ro" # The user which has read only access to the repositories.

GIT_REP_BASE_PATH="/path/to/GitRepositories" # The repositories base path.

GIT_LOG_FILE="/var/log/git.log" # The git daemon log file. The user which runs the script must have the right write permissions

/path/to/git daemon --reuseaddr --verbose --user=$GIT_RO_USER --base-path=$GIT_REP_BASE_PATH $GIT_REP_BASE_PATH >> $GIT_LOG_FILE 2>&1

# Or if you like to keep the error log separated, uncomment the following lines and comment the previous one:
#GIT_ERR_LOG_FILE="/var/log/git_err.log" # The error log file
#/path/to/git daemon --reuseaddr --verbose --user=$GIT_RO_USER --base-path=$GIT_REP_BASE_PATH $GIT_REP_BASE_PATH >> $GIT_LOG_FILE 2>> $GIT_ERR_LOG_FILE

Where /path/to/git is the path to the git command. 其中/path/to/git是git命令的路径。 I use it with launchd on my OS X machine cause I have noticed that you can't setup StandardOutPath and StandardErrorPath keys for the daemon using a .plist file. 我在我的OS X机器上将它与launchd一起使用,因为我注意到你无法使用.plist文件为守护进程设置StandardOutPathStandardErrorPath键。

Hope it helps you too! 希望它也能帮到你!

Where do I see the logs of git daemon? 我在哪里可以看到git守护进程的日志?

Git 2.17 (Q1 2018) can help, since the log from " git daemon " can be redirected with a new option; Git 2.17(2018年第一季度)可以提供帮助,因为来自“ git daemon ”的日志可以通过新选项重定向; one relevant use case is to send the log to standard error (instead of syslog) when running it from inetd . 一个相关的用例是从inetd运行日志时将日志发送到标准错误(而不是syslog)。

See commit 0c591ca (04 Feb 2018) by Lucas Werkmeister ( lucaswerkmeister ) . 参见Lucas Werkmeister( lucaswerkmeister )的 提交0c591ca (2018年2月4日
Helped-by: Ævar Arnfjörð Bjarmason ( avar ) , Junio C Hamano ( gitster ) , and Eric Sunshine ( sunshineco ) . 帮助: ÆvarArnfjörðBjarmason( avarJunio C gitstergitsterEric Sunshine( sunshineco
(Merged by Junio C Hamano -- gitster -- in commit c2bd43d , 21 Feb 2018) (由Junio C gitster合并- gitster -提交c2bd43d ,2018年2月21日)

daemon : add --log-destination=(stderr|syslog|none) daemon :add --log-destination=(stderr|syslog|none)

This new option can be used to override the implicit --syslog of --inetd , or to disable all logging. 此新选项可用于覆盖--syslog的隐式--inetd ,或禁用所有日志记录。 (While --detach also implies --syslog , --log-destination=stderr with --detach is useless since --detach disassociates the process from the original stderr.) --syslog is retained as an alias for --log-destination=syslog . (虽然--detach也暗示--syslog , - --log-destination=stderr with --detach是无用的,因为--detach将进程与原始stderr解除关联。) - --syslog被保留为--log-destination=syslog的别名--log-destination=syslog

--log-destination always overrides implicit --syslog regardless of option order. --log-destination始终覆盖隐式--syslog而不考虑选项顺序。
This is different than the “last one wins” logic that applies to some implicit options elsewhere in Git, but should hopefully be less confusing. 这与适用于Git中其他一些隐式选项的“最后一个胜利”逻辑不同,但应该不那么容易混淆。
(I also don't know if all implicit options in Git follow “last one wins”.) (我也不知道Git中的所有隐含选项是否遵循“最后一个获胜”。)

The combination of --inetd with --log-destination=stderr is useful, for instance, when running git daemon as an instanced systemd service (with associated socket unit). 例如,当将git daemon作为实例化systemd服务(具有关联的套接字单元)运行时, --inetd--log-destination=stderr的组合--inetd用。
In this case, log messages sent via syslog are received by the journal daemon, but run the risk of being processed at a time when the git daemon process has already exited (especially if the process was very short-lived, eg due to client error), so that the journal daemon can no longer read its cgroup and attach the message to the correct systemd unit (see systemd/systemd issue 2913 ). 在这种情况下,日志守护程序会收到通过syslog发送的日志消息,但是在git daemon进程已经退出时会冒被处理的风险(特别是如果进程非常短暂,例如由于客户端错误),以便日志守护程序无法再读取其cgroup并将消息附加到正确的systemd单元(请参阅systemd / systemd issue 2913 )。 Logging to stderr instead can solve this problem, because systemd can connect stderr directly to the journal daemon, which then already knows which unit is associated with this stream. 记录到stderr可以解决这个问题,因为systemd可以直接将stderr连接到日志守护进程,后者已经知道哪个单元与该流关联。


Git 2.18 (Q2 2018) make things more robust, since the recent introduction of " --log-destination " option to " git daemon " did not work well when the daemon was run under " --inetd " mode. Git 2.18(2018年第二季度)使事情变得更加强大,因为最近在“ git daemon ”中引入“ --log-destination ”选项在守护程序在“ --inetd ”模式下运行时效果--inetd

daemon.c : fix condition for redirecting stderr daemon.c :修复重定向stderr条件

Since the --log-destination option was added in 0c591ca ("daemon: add --log-destination=(stderr|syslog|none) ", 2018-02-04, Git 2.17) with the explicit goal of allowing logging to stderr when running in inetd mode, we should not always redirect stderr to /dev/null in inetd mode, but rather only when stderr is not being used for logging. 由于--log-destination选项是在0c591ca (“守护进程:添加--log-destination=(stderr|syslog|none) ”,2018-02-04,Git 2.17)中添加的,其明确目标是允许记录到stderrinetd模式下运行时,我们不应该总是在inetd模式下将stderr重定向到/dev/null ,而是仅在stderr没有用于日志记录时。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM