Open mchhil-incomm opened 1 month ago
I have mixed feelings here. This doesn't solve another very common situation. A user runs as root once (because you know, that what happens most of the time with non Unix people), and then when the system runs as a regular user, it still can't write the log, and you have the same visibility problem.
Wouldn't it be better to just bubble up an exception so that the logger configuration gets renamed as .BAD
raising some visibility on the problem?
If there's a typo in the log path, we still want to correct it instead of creating a new directory somewhere, perhaps out of a volume or filesystem we really want.
As always, I like to be proven wrong (which is usually an easy task :) so I'm listening to your comments.
My opinion is attempt the directory and file creation, if it still fails make the logger a .BAD and do a printstacktrace. printstacktrace because you may not have redirected the standard outs to the q2 log which can help with debugging.
My case is a little weirds we write different logs in addition to q2 to the log directory, the others create the log folder (logback and jetty), so down the line the q2 starts getting written there as the log folder is now available, though initially it failed.
In my test case I create the log (or xyz as in the example) folder in the unit test before starting q2, so we worked around it.
What if we add a property for that?
So the dev/maintainer has a choice. It can be false in prod and true in dev or test envs via Environment properties or different configurations
Property would work, it's the easiest way to keep things backwards compatible and move forward with updated development.
If the
logName
is likexyx/a.log
and the xyz folder does not exist a FileNotFound exception is thrown and since the log file is not there it gets lost.https://github.com/jpos/jPOS/blob/master/jpos/src/main/java/org/jpos/util/RotateLogListener.java#L154-L161
I have made a local code change to create the path directories
And a unit test for my environment where the logger deploy has the appropriate prefix suffix