How to stop Jsprit from printing logs to the console programmatically?

293 views
Skip to first unread message

Jason

unread,
Sep 11, 2015, 4:01:57 PM9/11/15
to jsprit-mailing-list
Firstly, I am very grateful for the amazing Jsprit toolkit developed by Stefan Schröder and improved by many kind coders, which is really easy to use and powerful to solve VRPs.

Now I have finished my programme but I need to stop Jsprit from printing logs to the console. I have tried many ways to do so, but failed. Is it possible to disable outputs programmatically?

Thanks and Best Regards.

Stefan Schroeder

unread,
Sep 11, 2015, 4:19:16 PM9/11/15
to jsprit-ma...@googlegroups.com
Thank you for your kind words.

Put this for example into your resource folder. It configures jsprit's logger to only log error msg to STDOUT.

Best,
Stefan

Am 11/09/15 um 22:01 schrieb Jason:
Firstly, I am very grateful for the amazing Jsprit toolkit developed by Stefan Schröder and improved by many kind coders, which is really easy to use and powerful to solve VRPs.

Now I have finished my programme but I need to stop Jsprit from printing logs to the console. I have tried many ways to do so, but failed. Is it possible to disable outputs programmatically?

Thanks and Best Regards.

--
You received this message because you are subscribed to the Google Groups "jsprit-mailing-list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jsprit-mailing-...@googlegroups.com.
To post to this group, send email to jsprit-ma...@googlegroups.com.
Visit this group at http://groups.google.com/group/jsprit-mailing-list.
For more options, visit https://groups.google.com/d/optout.

log4j2.xml

Jason

unread,
Sep 11, 2015, 4:36:12 PM9/11/15
to jsprit-mailing-list
Hi Stefan,

Thanks for the prompt reply.

I put the xml file into the /src folder, but the logger still prints. Please find a screenshot in the attached file. Perhaps the folder is wrong?

Thanks.

Jason
2015-09-12_042922.png

Stefan Schroeder

unread,
Sep 11, 2015, 5:43:59 PM9/11/15
to jsprit-ma...@googlegroups.com
I do not know eclipse that well. You need to put the log4j2.xml file into the classpath. Maybe this helps? http://stackoverflow.com/questions/17944905/getting-log4j2-to-work-with-eclipse

Am 11/09/15 um 22:36 schrieb Jason:

Jason

unread,
Sep 12, 2015, 2:22:09 AM9/12/15
to jsprit-mailing-list
Hi Stefan,

Thanks for your help. I actually has tried this solution, but no joy. My application based on Repast has to solve thousands VRPs in several minutes hopefully. Therefore, I try to disable printing for speed.

I find that in your XML file, the logger name of jsprit is "jsprit.core". So I added the following code before building a VRP:

List<Logger> loggers = Collections.<Logger>list(LogManager.getCurrentLoggers());
loggers.add(LogManager.getRootLogger());
for ( Logger logger : loggers ) {
   logger.setLevel(Level.OFF);
   System.out.println(logger.getName() +" ----- "+ logger.getLevel());
}
System.out.println("all loggers are off");

Logger jspritLogger = LogManager.getLogger("jsprit.core");
System.out.println("see Jsprit level: "+ jspritLogger.getLevel());
jspritLogger.setLevel(Level.OFF);
System.out.println("see Jsprit again: "+ jspritLogger.getLevel());
final VehicleRoutingProblem problem = vrpBuilder.build();

it prints:

MessageCenter.INTERNAL.repast.simphony.visualization.engine.DisplayProducer ----- OFF
MessageCenter.INTERNAL.repast.simphony.chart2.XYDataSinkValueSeries ----- OFF
MessageCenter.INTERNAL.repast.simphony.scenario.data.ContextData ----- OFF
MessageCenter.INTERNAL.repast.simphony.chart2.engine.TimeSeriesComponentControllerAction ----- OFF
org.apache.velocity.runtime.log.SimpleLog4JLogSystem ----- OFF
MessageCenter.INTERNAL.repast.simphony.random.DefaultRandomRegistry ----- OFF
MessageCenter.INTERNAL.repast.simphony.engine.controller.DefaultController ----- OFF
MessageCenter.INTERNAL.saf.core.runtime.Boot ----- OFF
MessageCenter.INTERNAL.repast ----- OFF
MessageCenter.INTERNAL.repast.simphony.dataLoader.engine.DataLoaderControllerAction ----- OFF
MessageCenter.INTERNAL.repast.simphony.parameter.ParametersCreator ----- OFF
MessageCenter.INTERNAL.repast.simphony.engine.watcher.WatcheeInstrumentor ----- OFF
MessageCenter.INTERNAL.repast.simphony.ui.GUIScheduleRunner ----- OFF
MessageCenter.INTERNAL.repast.simphony.scenario.ScenarioCPInitializer ----- OFF
MessageCenter.INTERNAL.repast.simphony.engine.environment.ProjectionRegistry ----- OFF
MessageCenter.INTERNAL.repast.simphony.engine.watcher.WatcheeDataFinder ----- OFF
MessageCenter.INTERNAL.repast.simphony.scenario.ObjectActionLoader ----- OFF
MessageCenter.INTERNAL.simphony.util.messages.MessageCenter ----- OFF
MessageCenter.INTERNAL.repast.simphony.visualization.editedStyle.EditedStyleOGL2D ----- OFF
MessageCenter.INTERNAL.repast.simphony.engine.watcher.WatcherTrigger ----- OFF
MessageCenter.INTERNAL.repast.simphony.visualization.engine.VisualizationRegistry ----- OFF
MessageCenter.INTERNAL.repast.simphony.ui.RSUIPlugin ----- OFF
MessageCenter.INTERNAL.repast.simphony.util.SimUtilities ----- OFF
MessageCenter.INTERNAL.repast.simphony.util.wizard.DynamicWizard ----- OFF
MessageCenter.INTERNAL.repast.simphony.scenario.ScenarioWatcheeInitializer ----- OFF
MessageCenter.INTERNAL.repast.simphony.ui.RSGUIConstants ----- OFF
MessageCenter.INTERNAL.repast.simphony.engine.schedule.DynamicTargetAction ----- OFF
MessageCenter.INTERNAL.saf.core.ui.MenuOrder ----- OFF
MessageCenter.INTERNAL.repast.simphony.freezedry.wizard.FreezeDryButtonModel ----- OFF
MessageCenter.INTERNAL.saf.core.ui.GUIBarManager ----- OFF
repast.simphony.batch.ssh.SSHSessionFactory ----- OFF
MessageCenter.INTERNAL.repast.simphony.data2.engine.DataSetComponentControllerAction ----- OFF
MessageCenter.INTERNAL.repast.simphony.ui.RSApplication ----- OFF
MessageCenter.INTERNAL.repast.simphony.visualization.engine.DisplayComponentControllerAction ----- OFF
MessageCenter.INTERNAL.repast.simphony.data.analysis.AnalysisPluginWizard ----- OFF
MessageCenter.INTERNAL.repast.simphony.ui.widget.SnapshotTaker ----- OFF
MessageCenter.INTERNAL.repast.simphony.scenario.ScenarioCreator ----- OFF
MessageCenter.INTERNAL.repast.simphony.scenario.AbstractActionLoader ----- OFF
MessageCenter.INTERNAL.repast.simphony.dataLoader.engine.CNDataLoaderActionLoader ----- OFF
org.apache.commons ----- OFF
repast.simphony.plugin ----- OFF
MessageCenter.INTERNAL.saf.core.ui.dock.Perspective ----- OFF
MessageCenter.INTERNAL.repast.simphony.util.Settings ----- OFF
repast.simphony.batch ----- OFF
MessageCenter.INTERNAL.repast.simphony.util.wizard.WizardPluginUtil ----- OFF
MessageCenter.INTERNAL.repast.simphony.random.RandomHelper ----- OFF
MessageCenter.INTERNAL.repast.simphony.ui.RSGui ----- OFF
MessageCenter.INTERNAL.saf ----- OFF
MessageCenter.INTERNAL.repast.simphony.util.ClassUtilities ----- OFF
MessageCenter.INTERNAL.repast.simphony.data.analysis.AnalysisPluginRunner ----- OFF
org.java.plugin ----- OFF
MessageCenter.INTERNAL.repast.simphony.scenario.ScenarioLoader ----- OFF
MessageCenter.INTERNAL.repast.simphony.engine.environment.DefaultScheduleRunner ----- OFF
root ----- OFF
all loggers are off
see Jsprit level: null
see Jsprit again: OFF

2015-09-12T13:55:23,582 [Thread-7] INFO  jsprit.core.problem.VehicleRoutingProblem - setup problem: [fleetSize=FINITE][#jobs=9][#vehicles=4][#vehicleTypes=1][transportCost=jsprit.core.util.VehicleRoutingTransportCostsMatrix@59223996][activityCosts=[name=defaultActivityCosts]]
2015-09-12T13:55:23,803 [Thread-7] INFO  jsprit.core.algorithm.VehicleRoutingAlgorithm - algorithm starts: [maxIterations=2000]
2015-09-12T13:55:23,803 [Thread-7] INFO  jsprit.core.algorithm.InsertionInitialSolutionFactory - create initial solution
2015-09-12T13:55:23,834 [Thread-7] INFO  jsprit.core.algorithm.acceptor.SchrimpfInitialThresholdGenerator - prepare schrimpfAcceptanceFunction, i.e. determine initial threshold
2015-09-12T13:55:23,850 [Thread-7] INFO  jsprit.core.algorithm.VehicleRoutingAlgorithm - algorithm starts: [maxIterations=20]
2015-09-12T13:55:23,850 [Thread-7] INFO  jsprit.core.algorithm.InsertionInitialSolutionFactory - create initial solution
2015-09-12T13:55:23,865 [Thread-7] INFO  jsprit.core.algorithm.VehicleRoutingAlgorithm - iterations start
2015-09-12T13:55:23,897 [Thread-7] INFO  jsprit.core.algorithm.VehicleRoutingAlgorithm$Counter - iterations 1
2015-09-12T13:55:23,897 [Thread-7] INFO  jsprit.core.algorithm.VehicleRoutingAlgorithm$Counter - iterations 2
2015-09-12T13:55:23,912 [Thread-7] INFO  jsprit.core.algorithm.VehicleRoutingAlgorithm$Counter - iterations 4
2015-09-12T13:55:23,990 [Thread-7] INFO  jsprit.core.algorithm.VehicleRoutingAlgorithm$Counter - iterations 8
2015-09-12T13:55:24,100 [Thread-7] INFO  jsprit.core.algorithm.VehicleRoutingAlgorithm$Counter - iterations 16
2015-09-12T13:55:24,147 [Thread-7] INFO  jsprit.core.algorithm.VehicleRoutingAlgorithm - iterations end at 20 iterations
2015-09-12T13:55:24,147 [Thread-7] INFO  jsprit.core.algorithm.VehicleRoutingAlgorithm - took 0.297 seconds
2015-09-12T13:55:24,318 [Thread-7] INFO  jsprit.core.algorithm.acceptor.SchrimpfInitialThresholdGenerator - took 0.484 seconds
2015-09-12T13:55:24,318 [Thread-7] INFO  jsprit.core.algorithm.acceptor.SchrimpfInitialThresholdGenerator - ---------------------------------------------------------------------
2015-09-12T13:55:24,318 [Thread-7] INFO  jsprit.core.algorithm.VehicleRoutingAlgorithm - iterations start
2015-09-12T13:55:24,318 [Thread-7] INFO  jsprit.core.algorithm.VehicleRoutingAlgorithm$Counter - iterations 1
2015-09-12T13:55:24,334 [Thread-7] INFO  jsprit.core.algorithm.VehicleRoutingAlgorithm$Counter - iterations 2
2015-09-12T13:55:24,350 [Thread-7] INFO  jsprit.core.algorithm.VehicleRoutingAlgorithm$Counter - iterations 4
2015-09-12T13:55:24,381 [Thread-7] INFO  jsprit.core.algorithm.VehicleRoutingAlgorithm$Counter - iterations 8
2015-09-12T13:55:24,412 [Thread-7] INFO  jsprit.core.algorithm.VehicleRoutingAlgorithm$Counter - iterations 16
2015-09-12T13:55:24,475 [Thread-7] INFO  jsprit.core.algorithm.VehicleRoutingAlgorithm$Counter - iterations 32
2015-09-12T13:55:24,584 [Thread-7] INFO  jsprit.core.algorithm.VehicleRoutingAlgorithm$Counter - iterations 64
2015-09-12T13:55:24,756 [Thread-7] INFO  jsprit.core.algorithm.VehicleRoutingAlgorithm$Counter - iterations 128
2015-09-12T13:55:24,975 [Thread-7] INFO  jsprit.core.algorithm.VehicleRoutingAlgorithm$Counter - iterations 256
2015-09-12T13:55:25,022 [Thread-7] INFO  jsprit.core.algorithm.VehicleRoutingAlgorithm - premature algorithm termination at iteration 300
2015-09-12T13:55:25,022 [Thread-7] INFO  jsprit.core.algorithm.VehicleRoutingAlgorithm - iterations end at 300 iterations
2015-09-12T13:55:25,022 [Thread-7] INFO  jsprit.core.algorithm.VehicleRoutingAlgorithm - took 1.219 seconds

It seems that, all loggers, including the root logger, are turned off successfully; the "jsprit.core" logger has no log level at the beginning, maybe it does not exist?

Howerver, the messages still appear even I turned off all these loggers. Maybe I should move these codes to somewhere proper?

Best Regards,

Jason

Stefan Schröder

unread,
Sep 14, 2015, 3:24:19 AM9/14/15
to jsprit-mailing-list
Hi Jason,

Sorry. Here, I cannot help you anymore. However, I guess that you do not gain much speed when turning off jsprit's logger (since the logger just prints infos, i.e. 10 lines or so). But still, I see that it is unsatisfying not to control the logger.

Best
Stefan
Reply all
Reply to author
Forward
0 new messages