Redirecting stdout/stderr from a Caplet
Hi,
My company is currently switching from a "custom app launcher" to a custom Caplet so that we can benefit from the standard bits (and Caplets) that Capsule brings. One of our needs is being able to redirect the stdout and stderr of the capsule process in our Caplet.
Currently the logging is done through the STDOUT and STDERR variables which are initialized from the System.out and System.err variables. This is the change that introduced this behavior: https://github.com/puniverse/capsule/commit/5e08a996f4bad7586a6f3e383b8197a05add6426
Is there a reason/need for not manipulating the System.out and System.err variables directly? Would you consider a PR for doing so?
Cheers and thanks for reading
TBH, I don't recall at the moment why I made that change, so let me think about it. But I believe there are logs emitted even before caplets are loaded; won't those bother you? Also, can you explain the need? Why is redirecting the stdout/err on the command line insufficient?
Sure, thanks for the feedback
Basically we're making a caplet that is used to launch our applications without the need for a script All the setup is done in a configuration file such as JVM params and product specific things which are set through system properties (legacy thing) This includes stdout redirection, gc logs etc
I didn't check how early things are logged yet as I first wanted to know if you'd consider the change But I can try it out and let you know
BTW, to override stdout/err in the application process (which, I think, is even more important to you), you'll need to do that by overriding the agent method, which is called by the capsule's agent's premain, before the application's classes are loaded.