Reputation: 816
I want to get away from using a string buffer and System.out.println in Java agents.
I want to use java.util.Logger.
When I log using
logger.info("logger started")
output in the Domino Server Console
[0FDC:000D-1258] 06/07/2018 03:13:57 PM Agent Manager: Agent error: Jun 07, 2018 3:13:57 PM TransferDocsToServerNSF NotesMain INFO: logger started.
Notice the Domino platform added "Agent error" before the output when using Level.INFO
I then tried using .logp with Level.FINE and no output shows up.
logger.setLevel(Level.ALL); or logger.setLevel(Level.FINE);
logger.logp(Level.FINE,this.getClass().getSimpleName(),"main","logger started.");
output: No output. Anything lower than Level.INFO does not print.
How can I target the Domino logging to show Level.FINE?
And, what can I do for INFO for Domino not to consider all Level.INFO to be errors?
Upvotes: 2
Views: 1325
Reputation: 816
I was able to print logging at different levels after editing this file on the server:
(server install) IBM/Domino/jvm/lib/logging.properties
# Default global logging level.
# This specifies which kinds of events are logged across
# all loggers. For any given facility this global level
# can be overriden by a facility specific level
# Note that the ConsoleHandler also has a separate level
# setting to limit messages printed to the console.
.level= FINEST
# Limit the message that are printed on the console to INFO and above.
java.util.logging.ConsoleHandler.level = FINEST
Testing Java code
logger = Logger.getLogger("com.xpagesbeast");
logger.setUseParentHandlers(false); //do not use the global logger (avoid two outputs per log)
create a custom handler if one does not exist, watch our here, you can create more than one the JVM will track.
if(logger.getHandlers().length == 0){
System.out.println("Adding a new handler");
consoleHandler = new ConsoleHandler();
logger.addHandler(consoleHandler);
}
logger.getHandlers()[0].setLevel(Level.INFO);
logger.severe("test severe logging " + logger.getName());
logger.warning("test warning logging " + logger.getName());
logger.info("test info logging " + logger.getName());
logger.finer("test finer logging " + logger.getName());
logger.finest("test finest logging " + logger.getName());
Now I can set a debug flag in a Database or environment variable and assign the logging level as detailed as I want.
For example, if I want to debug the application, I can set a value in a database that is read by the application that determines what logging level that handler will use.
Upvotes: 3