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

Delayed and sometimes incomplete log messages #11

Open
selvanair opened this issue Nov 11, 2016 · 2 comments
Open

Delayed and sometimes incomplete log messages #11

selvanair opened this issue Nov 11, 2016 · 2 comments

Comments

@selvanair
Copy link

selvanair commented Nov 11, 2016

When openvpn is started by the service there is a rather long delay (up to ~1min) before messages appear in the log. When the service is stopped the log sometimes appear incomplete (using verb 4)

Especially when the config has an invlaid option and the openvpn process exits promptly, nothing appears in the log file. As openvpn flushes the output after every message, this looks like a buffering issue due to log redirection. Using --log instead of stdout redirection may be better.

@xkjyeah
Copy link
Owner

xkjyeah commented Nov 21, 2016

Is it alright to use synchronous IO? I was concerned about performance,
although for a log file the performance cost should be negligible

On Nov 11, 2016 23:54, "Selva Nair" notifications@github.com wrote:

When openvpn is started by the service there is a rather long delay (up to
~1min) before messages appear in the log. When the service is stopped the
log sometimes appear incomplete (using verb 4)

Especially when the config has an invlaid option and the openvpn exits
promptly, nothing appears in the log file. As openvpn flushes the output
after every message, this looks like a buffering issue due to log
redirection. Using --log instead of stdout redirection may be better.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#11, or mute the thread
https://github.com/notifications/unsubscribe-auth/ACiTR71MpOtYKxeLOJB-roAliFMLU615ks5q9I-pgaJpZM4Kv4F3
.

@selvanair
Copy link
Author

With the logfile set to autoflush and use of exit event, loss of logs should be unlikely now. So unless anyone notices lost messages, leave it at it for now?

There are two minor issues left:
(i) WriteToLog should write only after checking something like (!String.IsNullOrEmpty(e.Data)) -- else EOF (once each for each stdin/stdout) etc causes some unwanted output in the log file at each restart of the process.
(ii) As per MSDN docs async IO needs a WaitForExit() without a timeout to ensure all output is captured when the process exits but we do not want to use WaitForexit() as it blocks.

In my view the best option is just to redirect stdin/stderr to NUL and use "--log logfilename" or "--log-append logfilename" in the command line. Let openvpn.exe handle the log file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants