[英]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文件为守护进程设置StandardOutPath
和StandardErrorPath
键。
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(
avar
) , Junio C gitster
( gitster
)和Eric 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 runninggit daemon
as an instancedsystemd
service (with associated socket unit).例如,当将
git daemon
作为实例化systemd
服务(具有关联的套接字单元)运行时,--inetd
与--log-destination=stderr
的组合--inetd
用。
In this case, log messages sent viasyslog
are received by the journal daemon, but run the risk of being processed at a time when thegit 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 itscgroup
and attach the message to the correctsystemd
unit (see systemd/systemd issue 2913 ).在这种情况下,日志守护程序会收到通过
syslog
发送的日志消息,但是在git daemon
进程已经退出时会冒被处理的风险(特别是如果进程非常短暂,例如由于客户端错误),以便日志守护程序无法再读取其cgroup
并将消息附加到正确的systemd
单元(请参阅systemd / systemd issue 2913 )。 Logging tostderr
instead can solve this problem, becausesystemd
can connectstderr
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 redirectingstderr
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 tostderr
when running ininetd
mode, we should not always redirectstderr
to/dev/null
in inetd mode, but rather only whenstderr
is not being used for logging.由于
--log-destination
选项是在0c591ca (“守护进程:添加--log-destination=(stderr|syslog|none)
”,2018-02-04,Git 2.17)中添加的,其明确目标是允许记录到stderr
在inetd
模式下运行时,我们不应该总是在inetd
模式下将stderr
重定向到/dev/null
,而是仅在stderr
没有用于日志记录时。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.