Dave Welchons
2014-09-04 21:32:55 UTC
Dear jade-develop mailing list,
I initially placed many prints in my AlertAgent.java application. If I
wanted to turn them off, I had to change the source code. So I thought I
would use java.util.logging as described in the sentence "including
application-specific logging messages" Section 3.7.5 (p. 46) of "Developing
Multi-Agent Systems With JADE". I wanted an output file specific to a
specific agent (i.e. multiple output files with one for each agent), and I
read that java.util.logging does not allow that in the java.util.logging
config file, so I attempted to add a FileHandler in my agent source code as
shown below. I also passed in the argument
"-Djava.util.logging.config.file=logging.properties" and I created the file
logging.properties as shown below, similar to p. 47 of the book. In the
config file I specified that the alert agent logging level should be "fine"
for its package com.brsc.masaide.alertagent. When I run my application I
only see the "info()" log statements, but I do not see the "fine()" log
statements.
Can you see what I am doing wrong?
Thanks,
Dave Welchons
P.S. Maybe this is just a question for java.util.logging use and not
related to JADE, and if so, I apologize for wasting your time
***************************
Selected source code statements in AlertAgent.java:
***************************
package com.brsc.masaide.alertagent;
.
public class AlertAgent extends Agent {
private Logger logger =
jade.util.Logger.getMyLogger(this.getClass().getName());
.
protected void setup()
{
// Create file logger if configuration file level high enough
if (logger.isLoggable(jade.util.Logger.FINE)) {
FileHandler fileHandler;
try {
fileHandler = new FileHandler("AlertAgent_Logger.txt");
} catch (SecurityException | IOException e) {
logger.severe(" AlertAgent.java: FileHandler exception =
"+e.getLocalizedMessage());
e.printStackTrace();
return;
}
fileHandler.setFormatter(new SimpleFormatter());
fileHandler.setLevel(Level.FINE);
logger.addHandler(fileHandler);
}
// Note commented out below. Only see middle logger (logger.fine())
below if next line uncommented.
// Otherwise do not see middle log, implying that the default "info" is
in effect.
// Config file setting of level to "fine" for this package
"com.brsc.masaide.alertagent" does not seem to have an effect.
//logger.setLevel(Level.FINE);
// Print agent data
logger.info(" AlertAgent.java: setup(): my local-name is
"+getAID().getLocalName());
logger.fine(" AlertAgent.java: setup(): my GUID is
"+getAID().getName());
logger.info(" AlertAgent.java: setup(): my AID is: "+getAID());
***********************
Config file logging.properties:
***********************
# Set default log level to INFO, and then override for those packages that
# require more debug info
.level = INFO
# Add ConsoleHandler here for all classes.
# A unique FileHandler will be added in each module to provide different
file
# for each module. If specified FileHandler here one file would be used
# for output of all modules (I think).
handlers = java.util.logging.ConsoleHandler, java.util.logging.FileHandler
# Modify default level for all handlers which will be overridden below
# with each package level.
java.util.logging.ConsoleHandler.level = ALL
java.util.logging.FileHandler.level = ALL
# Set all handlers to simple (non-xml) format
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
# Set log level for my class of interest to FINE
com.brsc.masaide.alertagent.level = FINE
# Wild guess below since above didn't work, since I think I saw this below
somewhere in JADE documentation
com_brsc_masaide_alertagent_loglevel = FINE
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://jade.tilab.com/pipermail/jade-develop/attachments/20140904/71a53dfb/attachment.html>
I initially placed many prints in my AlertAgent.java application. If I
wanted to turn them off, I had to change the source code. So I thought I
would use java.util.logging as described in the sentence "including
application-specific logging messages" Section 3.7.5 (p. 46) of "Developing
Multi-Agent Systems With JADE". I wanted an output file specific to a
specific agent (i.e. multiple output files with one for each agent), and I
read that java.util.logging does not allow that in the java.util.logging
config file, so I attempted to add a FileHandler in my agent source code as
shown below. I also passed in the argument
"-Djava.util.logging.config.file=logging.properties" and I created the file
logging.properties as shown below, similar to p. 47 of the book. In the
config file I specified that the alert agent logging level should be "fine"
for its package com.brsc.masaide.alertagent. When I run my application I
only see the "info()" log statements, but I do not see the "fine()" log
statements.
Can you see what I am doing wrong?
Thanks,
Dave Welchons
P.S. Maybe this is just a question for java.util.logging use and not
related to JADE, and if so, I apologize for wasting your time
***************************
Selected source code statements in AlertAgent.java:
***************************
package com.brsc.masaide.alertagent;
.
public class AlertAgent extends Agent {
private Logger logger =
jade.util.Logger.getMyLogger(this.getClass().getName());
.
protected void setup()
{
// Create file logger if configuration file level high enough
if (logger.isLoggable(jade.util.Logger.FINE)) {
FileHandler fileHandler;
try {
fileHandler = new FileHandler("AlertAgent_Logger.txt");
} catch (SecurityException | IOException e) {
logger.severe(" AlertAgent.java: FileHandler exception =
"+e.getLocalizedMessage());
e.printStackTrace();
return;
}
fileHandler.setFormatter(new SimpleFormatter());
fileHandler.setLevel(Level.FINE);
logger.addHandler(fileHandler);
}
// Note commented out below. Only see middle logger (logger.fine())
below if next line uncommented.
// Otherwise do not see middle log, implying that the default "info" is
in effect.
// Config file setting of level to "fine" for this package
"com.brsc.masaide.alertagent" does not seem to have an effect.
//logger.setLevel(Level.FINE);
// Print agent data
logger.info(" AlertAgent.java: setup(): my local-name is
"+getAID().getLocalName());
logger.fine(" AlertAgent.java: setup(): my GUID is
"+getAID().getName());
logger.info(" AlertAgent.java: setup(): my AID is: "+getAID());
***********************
Config file logging.properties:
***********************
# Set default log level to INFO, and then override for those packages that
# require more debug info
.level = INFO
# Add ConsoleHandler here for all classes.
# A unique FileHandler will be added in each module to provide different
file
# for each module. If specified FileHandler here one file would be used
# for output of all modules (I think).
handlers = java.util.logging.ConsoleHandler, java.util.logging.FileHandler
# Modify default level for all handlers which will be overridden below
# with each package level.
java.util.logging.ConsoleHandler.level = ALL
java.util.logging.FileHandler.level = ALL
# Set all handlers to simple (non-xml) format
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
# Set log level for my class of interest to FINE
com.brsc.masaide.alertagent.level = FINE
# Wild guess below since above didn't work, since I think I saw this below
somewhere in JADE documentation
com_brsc_masaide_alertagent_loglevel = FINE
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://jade.tilab.com/pipermail/jade-develop/attachments/20140904/71a53dfb/attachment.html>