logo separator

[mkgmap-dev] stdout, stderr and logging

From Mike Baggaley mike at tvage.co.uk on Thu Mar 15 09:32:48 GMT 2018

Dear all,

I redirect stdout and stderr to a file when running mkgmap, and then
incorporate the file in a build log file that holds the output from my whole
build process. I redirect using > mkgmap.log 2>& 1 at the end of the command
line, however, I seem to get a few files of the form mkgmap.log.0,
mkgmap.log.1 etc each containing just a few lines of echotags output. I
suspect that this is due to System.out.println not being thread safe, and if
two threads try to write at the same time, one of them ends up creating a
separate file.

I therefore suggest that we might consider using logging, which is thread
safe, rather than System.out.println. There are also a number of other
instances of error and warning messages being written using
System.out.println, and System.err.println, but most use logging. I think we
should standardise on one mechanism for outputting messages.

Replacing all the calls to System.out.println and System.err.println would
allow proper control using the -Dlog.config switch, which doesn't affect
System.out.println and System.err.println calls, and allow all output to be
directed to a file directly with that switch, instead of having to use
redirection. Because the log.config file allows multiple handlers, this
would not prevent the splitting of basic information to stdout with debug
information going to a file, if that is required.

Thoughts?

Regards,
Mike



More information about the mkgmap-dev mailing list