basex
basex copied to clipboard
Logging
Send stdout
and stderr
output to loggers, such as Log4J. If no loggers are found, output should stay as is.
Issues to solve:
- If the BaseX command-line interfaces are run (
basex
,basexclient
,basexgui
?), output should probably always be directed to standard out/err. This could e.g. be solved by an additional flag that indicates if loggers should be ignored. - Things are getting difficult with
basexserver
, which can both be run as service and as interactive tool (via-i
).
Since BaseX usage can not (and maybe better should not) predicted (lib vs tool vs dbms...), I propose adding hooks or annotations so it would be possible to introduce such functionality on another level. E.g. aspectj could be one way of allowing different "flavors".
Rergarding the .logs directory in the GUI, i wonder why there are no entries appearing when execution a (HTTP) query? is there anything to set?
I don't really see why some BaseX applications should write to the console: BaseX is not a small command-line tool. Are there other tools that depend on this console output? Using System.err/out is discouraged, except of course for pure command-line tools.
Would anyone really need console output, Log4J (and probably other loggers as well) can be configured to log to standard error/output.
The opposite, redirecting System.err/out to a logger, is possible also, so it's not a big deal and it's quite understandable if BaseX developers find more interesting issues to tackle ;-) It looks like System.err/out is only used in org.basex.util.Util, in 2 places, so I can propose a patch if you are interested.
My problem with BaseX writing to System.err is that a BaseX message is sometimes output in the middle of a log message when the logger outputs to the console. Context: BaseXServer embedded in a Java application, running as a JUnit unit test within Eclipse. I suppose it would not be a problem in a real application.
Hi @BenoitMaisonny, thanks for your offer; pull requests are always welcome. I guess one challenge will be to preserve the CLI features of BaseX (i.e. to decide when output to stdout is appropriate and when not).