marklogic-community / corb2

MarkLogic tool for bulk loading, processing, and reporting on content.
Other
19 stars 16 forks source link

Control logging from command-line options #244

Closed grtjn closed 4 days ago

grtjn commented 1 week ago

Hi,

We'd like to write log messages both to console and to file to be able to retrieve them more easily for processing and storing from NiFi. Using the ordinary linux redirect with > and such doesn't work well from within NiFi, so we are looking to provide params that will tell logging to write to a file as well as to console. Any ideas?

Cheers

hansenmc commented 1 week ago

CoRB uses the Java java.util.logging.Logger.

You can customize the behavior of the logger by applying your own logging.properties when you launch: -Djava.util.logging.config.file=logging.properties

With the logging.properties looking something like:

# Logging
handlers = java.util.logging.FileHandler, java.util.logging.ConsoleHandler
.level = ALL

# File Logging
java.util.logging.FileHandler.pattern = corb-out.log
java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
java.util.logging.FileHandler.level = INFO

# Console Logging
java.util.logging.ConsoleHandler.level = ALL
grtjn commented 1 week ago

And then you can probably provide the log file name from command line as well, I guess, or if needed, all those values?

hansenmc commented 1 week ago

Yes, that's what I meant when I showed -Djava.util.logging.config.file=logging.properties to specify the file that has those logging properties.

grtjn commented 4 days ago

It would have been nice if you could pass through a unique filename for the log from the command-line, but that appears not to be possible. We are running Corb headless from NiFi. We are now generating log properties with unique names at each run, and removing them afterwards. Bit cumbersome, but it works. Thanks..