I have been trying to add proper logging to my team’s WPILib (Java, 2022.1.1) project. So far, the best FRC specific tutorial I have found is this one, from 2018.
General Logging Question
Is this the best way, or is there a better way to collect debug information?
Question About Tutorial
It says I need to change the roboRIO’s JVM arguments, but it throws an error. I assume I’m not configuring it correctly:
To tell Java where your logging config file is, you must add one line to your build.gradle file. You must add one jvmArg to the deploy / artifacts / frcJavaArtifact section:
targets << "roborio"
jvmArgs = [ '-Djava.util.logging.config.file=/home/lvuser/deploy/logging.properties' ]
// Debug can be overridden by command line, for use with VSCode
debug = getDebugOrDefault(false)
Edit1: I clarified some stuff.
This builds for me, but haven’t tried anything more
Edit: I think I see what you meant now, did you place your snippet in deploy > targets > roborio(…) > artifacts?
I suppose I must have pasted it into the wrong location then. I don’t actually see the referenced location (
deploy / artifacts / frcJavaArtifact) in the defualt build.gradle file. Where did you place the snippet?:
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
def ROBOT_MAIN_CLASS = "frc.robot.Main"
// Define my targets (RoboRIO) and artifacts (deployable files)
// This is added by GradleRIO's backing project DeployUtils.
// Team number is loaded either from the .wpilib/wpilib_preferences.json
// or from command line. If not found an exception will be thrown.
// You can use getTeamOrDefault(team) instead of getTeamNumber if you
// want to store a team number in this file.
team = project.frc.getTeamNumber()
debug = project.frc.getDebugOrDefault(false)
// First part is artifact name, 2nd is artifact type
// getTargetTypeClass is a shortcut to get the class type using a string
// Static files artifact
def deployArtifact = deploy.targets.roborio.artifacts.frcJava
// Set to true to use debug for JNI.
wpi.java.debugJni = false
// Set this to true to enable desktop support.
def includeDesktopSupport = false
// Defining my dependencies. In this case, WPILib (+ friends), and vendor libraries.
// Also defines JUnit 4.
// Simulation configuration (e.g. environment variables).
wpi.sim.addGui().defaultEnabled = true
// Setting up my Jar File. In this case, adding all libraries into the main jar ('fat jar')
// in order to make them all available at runtime. Also adding the manifest so WPILib
// knows where to look for our Robot Class.
// Configure jar and deploy tasks
Thanks for the help! I reread your response now it builds correctly. Is there a reference for how to use build.gradle somewhere?
We don’t really have great documentation on the format. It’s something I’ve been meaning to do, but just haven’t had the time. The best bet now is the source code itself in the gradlerio repo.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.